Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BluToysApplication
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chengchong
BluToysApplication
Commits
7b0ef205
Commit
7b0ef205
authored
Feb 04, 2021
by
chengchong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qweq
parent
bc25d7a6
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
236 additions
and
210 deletions
+236
-210
SearchingActivity.java
...java/com/example/blu/toys/activity/SearchingActivity.java
+2
-1
SelectDeviceActivity.java
...a/com/example/blu/toys/activity/SelectDeviceActivity.java
+7
-11
SetTimeActivity.java
...n/java/com/example/blu/toys/activity/SetTimeActivity.java
+183
-185
BlePlay.java
app/src/main/java/com/example/blu/toys/ble/BlePlay.java
+11
-1
TrafficLightBean.java
.../com/example/blu/toys/ble/agreement/TrafficLightBean.java
+14
-1
LocalDateUtils.java
.../main/java/com/example/blu/toys/utils/LocalDateUtils.java
+12
-3
activity_set_time.xml
app/src/main/res/layout/activity_set_time.xml
+7
-8
No files found.
app/src/main/java/com/example/blu/toys/activity/SearchingActivity.java
View file @
7b0ef205
package
com
.
example
.
blu
.
toys
.
activity
;
package
com
.
example
.
blu
.
toys
.
activity
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
...
@@ -38,7 +39,7 @@ public class SearchingActivity extends BaseActivity {
...
@@ -38,7 +39,7 @@ public class SearchingActivity extends BaseActivity {
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
N
)
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
N
)
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
,
sticky
=
true
)
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
)
public
void
GoDeviceListPage
(
List
<
BleDevice
>
bleDevices
)
{
public
void
GoDeviceListPage
(
List
<
BleDevice
>
bleDevices
)
{
goActivity
(
SelectDeviceActivity
.
class
);
goActivity
(
SelectDeviceActivity
.
class
);
}
}
...
...
app/src/main/java/com/example/blu/toys/activity/SelectDeviceActivity.java
View file @
7b0ef205
...
@@ -38,35 +38,31 @@ public class SelectDeviceActivity extends BaseActivity {
...
@@ -38,35 +38,31 @@ public class SelectDeviceActivity extends BaseActivity {
@Override
@Override
public
void
init
(
Bundle
savedInstanceState
)
{
public
void
init
(
Bundle
savedInstanceState
)
{
EventBus
.
getDefault
().
register
(
this
);
EventBus
.
getDefault
().
register
(
this
);
}
@Override
public
void
initData
()
{
if
(
bleDevices
==
null
)
{
if
(
bleDevices
==
null
)
{
bleDevices
=
new
ArrayList
<>();
bleDevices
=
new
ArrayList
<>();
}
}
mRecyclerView
.
setLayoutManager
(
getLinearLayout
());
mRecyclerView
.
setLayoutManager
(
getLinearLayout
());
bleDeviceAdapter
=
new
BleDeviceAdapter
(
R
.
layout
.
ble_devices_item
,
bleDevices
);
bleDeviceAdapter
=
new
BleDeviceAdapter
(
R
.
layout
.
ble_devices_item
,
bleDevices
);
mRecyclerView
.
setAdapter
(
bleDeviceAdapter
);
mRecyclerView
.
setAdapter
(
bleDeviceAdapter
);
}
@Override
public
void
initData
()
{
bleDeviceAdapter
.
setOnItemClickListener
((
adapter
,
view
,
position
)
->
{
bleDeviceAdapter
.
setOnItemClickListener
((
adapter
,
view
,
position
)
->
{
BleDevice
bleDevice
=
(
BleDevice
)
adapter
.
getItem
(
position
);
BleDevice
bleDevice
=
(
BleDevice
)
adapter
.
getItem
(
position
);
BlePlay
.
getInstance
().
connectedBleDevice
(
bleDevice
);
BlePlay
.
getInstance
().
connectedBleDevice
(
bleDevice
);
});
});
showBleDevices
();
}
}
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
,
sticky
=
true
)
public
void
showBleDevices
()
{
public
void
showBleDevices
(
List
<
BleDevice
>
bles
)
{
List
<
BleDevice
>
bles
=
BlePlay
.
getInstance
().
getScanResultList
();
if
(
CollectionUtils
.
isEmpty
(
bles
))
{
if
(
CollectionUtils
.
isEmpty
(
bles
))
{
return
;
return
;
}
}
if
(
bleDevices
==
null
)
{
bleDevices
=
new
ArrayList
<>();
}
bleDevices
.
clear
();
bleDevices
.
clear
();
for
(
int
i
=
0
;
i
<
bles
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
bles
.
size
();
i
++)
{
BleDevice
bleDevice
=
bles
.
get
(
i
);
BleDevice
bleDevice
=
bles
.
get
(
i
);
String
deviceName
=
bleDevice
.
getName
();
String
deviceName
=
bleDevice
.
getName
();
...
...
app/src/main/java/com/example/blu/toys/activity/SetTimeActivity.java
View file @
7b0ef205
...
@@ -40,8 +40,10 @@ public class SetTimeActivity extends BaseActivity {
...
@@ -40,8 +40,10 @@ public class SetTimeActivity extends BaseActivity {
WheelView
wheelMinute
;
WheelView
wheelMinute
;
@BindView
(
R
.
id
.
wheel_second
)
@BindView
(
R
.
id
.
wheel_second
)
WheelView
wheelSecond
;
WheelView
wheelSecond
;
@BindView
(
R
.
id
.
wheel_am_pm
)
// @BindView(R.id.wheel_am_pm)
WheelView
wheelAmPm
;
// WheelView wheelAmPm;
// amPmList.add("AM");
// amPmList.add("PM");
@BindView
(
R
.
id
.
wheel_hour_dw
)
@BindView
(
R
.
id
.
wheel_hour_dw
)
WheelView
wheelHour_dw
;
WheelView
wheelHour_dw
;
...
@@ -59,20 +61,14 @@ public class SetTimeActivity extends BaseActivity {
...
@@ -59,20 +61,14 @@ public class SetTimeActivity extends BaseActivity {
TypefaceTextView
will
;
TypefaceTextView
will
;
private
ArrayList
<
String
>
hourList
=
new
ArrayList
<>();
private
ArrayList
<
String
>
hourList
=
new
ArrayList
<>();
private
ArrayList
<
String
>
minuteList
=
new
ArrayList
<>();
private
ArrayList
<
String
>
sixList
=
new
ArrayList
<>();
private
ArrayList
<
String
>
secondList
=
new
ArrayList
<>();
private
ArrayList
<
String
>
selectTime
=
new
ArrayList
<>();
private
ArrayList
<
String
>
amPmList
=
new
ArrayList
<>();
private
int
amOrPm
=
0
;
String
selectHour
;
String
selectHour
;
String
selectMin
;
String
selectMin
;
String
selectSec
;
String
selectSec
;
String
selectHour_dw
;
String
selectMin_dw
;
String
selectSec_dw
;
int
hour
=
0
;
int
hour
=
0
;
int
min
=
0
;
int
min
=
0
;
...
@@ -84,212 +80,225 @@ public class SetTimeActivity extends BaseActivity {
...
@@ -84,212 +80,225 @@ public class SetTimeActivity extends BaseActivity {
return
R
.
layout
.
activity_set_time
;
return
R
.
layout
.
activity_set_time
;
}
}
@Override
public
void
init
(
Bundle
savedInstanceState
)
{
wheelHour
.
setOnWheelViewListener
(
new
WheelView
.
OnWheelViewListener
()
{
//设置底部的时间
@Override
private
void
setDwTime
()
{
public
void
onSelected
(
int
selectedIndex
,
String
item
)
{
if
(
StringUtils
.
isEmpty
(
item
))
{
//不能动
int
indexHour
=
hourList
.
indexOf
(
selectHour
);
wheelHour
.
setSeletion
(
indexHour
);
return
;
}
Date
time
=
new
Date
();
Date
time
=
new
Date
();
Calendar
calendar
=
Calendar
.
getInstance
(
);
int
currHour
=
LocalDateUtils
.
getHour
(
time
);
calendar
.
setTime
(
time
);
int
currMinute
=
LocalDateUtils
.
getSecond
(
time
);
int
nowHour
=
calendar
.
get
(
Calendar
.
HOUR
);
//时(12小时制)
int
currSecond
=
LocalDateUtils
.
getMinute
(
time
);
if
(
item
.
startsWith
(
"0"
))
{
item
=
item
.
substring
(
1
);
}
//获取选择的时间
String
hour
=
wheelHour
.
getSeletedItem
();
Integer
selectHourTime
=
Integer
.
valueOf
(
item
);
String
minute
=
wheelMinute
.
getSeletedItem
();
if
(
selectHourTime
<
nowHour
)
{
String
second
=
wheelSecond
.
getSeletedItem
();
int
indexHour
=
hourList
.
indexOf
(
selectHour
);
wheelHour
.
setSeletion
(
indexHour
);
ToastUtils
.
show
(
"选择的时间不能小于当前时间"
);
return
;
}
// selectHour = item;
// //下面的小时 显示
// int dowHour = selectHourTime - nowHour;
// if (dowHour < 10) {
// selectHour_dw = "0" + dowHour;
// } else {
// selectHour_dw = String.valueOf(dowHour);
// }
// wheelHour_dw.setSeletion(hourList.indexOf(selectHour_dw));
}
int
selectHourTime
;
});
int
selectMinTime
;
int
selectSecTime
;
String
selectHour_dw
;
String
selectMin_dw
;
String
selectSec_dw
;
wheelMinute
.
setOnWheelViewListener
(
new
WheelView
.
OnWheelViewListener
()
{
//小时
@Override
if
(
hour
.
startsWith
(
"0"
))
{
public
void
onSelected
(
int
selectedIndex
,
String
item
)
{
hour
=
hour
.
substring
(
1
);
if
(
StringUtils
.
isEmpty
(
item
))
{
int
indexMinute
=
minuteList
.
indexOf
(
selectMin
);
wheelMinute
.
setSeletion
(
indexMinute
);
return
;
}
}
selectHourTime
=
Integer
.
parseInt
(
hour
);
Calendar
calendar
=
Calendar
.
getInstance
();
int
dowHour
=
selectHourTime
-
currHour
;
int
nowHour
=
calendar
.
get
(
Calendar
.
HOUR
);
//时(12小时制)
int
nowMin
=
calendar
.
get
(
Calendar
.
MINUTE
);
String
currentSelectHour
;
if
(
dowHour
<
10
)
{
if
(
selectHour
.
startsWith
(
"0"
))
{
selectHour_dw
=
"0"
+
dowHour
;
currentSelectHour
=
item
.
substring
(
1
);
}
else
{
}
else
{
currentSelectHour
=
selectHour
;
selectHour_dw
=
String
.
valueOf
(
dowHour
)
;
}
}
wheelHour_dw
.
setSeletion
(
selectTime
.
indexOf
(
selectHour_dw
));
Integer
selectHourTime
=
Integer
.
valueOf
(
currentSelectHour
);
if
(
selectHourTime
<
nowHour
)
{
//分钟
ToastUtils
.
show
(
"选择的时间不能小于当前时间"
);
if
(
minute
.
startsWith
(
"0"
))
{
return
;
minute
=
minute
.
substring
(
1
)
;
}
}
selectMinTime
=
Integer
.
parseInt
(
minute
);
int
dowMin
=
selectMinTime
-
currMinute
;
if
(
selectHourTime
>
nowHour
)
{
if
(
dowMin
<
10
)
{
selectMin
=
item
;
selectMin_dw
=
"0"
+
dowMin
;
}
else
{
selectMin_dw
=
String
.
valueOf
(
dowMin
);
}
}
wheelMinute_dw
.
setSeletion
(
sixList
.
indexOf
(
selectMin_dw
));
if
(
selectHourTime
==
nowHour
)
{
//秒
if
(
item
.
startsWith
(
"0"
))
{
if
(
second
.
startsWith
(
"0"
))
{
item
=
item
.
substring
(
1
);
second
=
second
.
substring
(
1
);
}
}
Integer
selectMinTime
=
Integer
.
valueOf
(
item
);
selectSecTime
=
Integer
.
parseInt
(
second
);
if
(
selectMinTime
<
nowMin
)
{
int
indexMinute
=
minuteList
.
indexOf
(
selectMin
)
;
int
dowSec
=
selectSecTime
-
currSecond
;
wheelMinute
.
setSeletion
(
indexMinute
);
if
(
dowSec
<
10
)
{
ToastUtils
.
show
(
"选择的时间不能小于当前时间"
)
;
selectSec_dw
=
"0"
+
dowSec
;
}
else
{
}
else
{
selectMin
=
item
;
selectSec_dw
=
String
.
valueOf
(
dowSec
)
;
}
}
wheelSecond_dw
.
setSeletion
(
sixList
.
indexOf
(
selectSec_dw
));
}
}
if
(
selectMin
.
startsWith
(
"0"
))
{
//设置顶部的时间
item
=
item
.
substring
(
1
);
private
void
setUpTime
()
{
String
hour
=
wheelHour
.
getSeletedItem
();
String
minute
=
wheelMinute
.
getSeletedItem
();
String
second
=
wheelSecond
.
getSeletedItem
();
String
dwHour
=
wheelHour_dw
.
getSeletedItem
();
String
dwMinute
=
wheelMinute_dw
.
getSeletedItem
();
String
dwSecond
=
wheelSecond_dw
.
getSeletedItem
();
int
selectHourTime
;
int
selectMinTime
;
int
selectSecTime
;
int
dwHourTime
;
int
dwMinTime
;
int
dwSecTime
;
if
(
hour
.
startsWith
(
"0"
))
{
hour
=
hour
.
substring
(
1
);
}
}
selectHourTime
=
Integer
.
parseInt
(
hour
);
Integer
selectMinTime
=
Integer
.
valueOf
(
item
);
if
(
dwHour
.
startsWith
(
"0"
))
{
dwHour
=
dwHour
.
substring
(
1
);
}
dwHourTime
=
Integer
.
parseInt
(
dwHour
);
//设置下面的时间
selectHourTime
=
selectHourTime
+
dwHourTime
;
// int dowMin = selectMinTime - nowMin;
if
(
selectHourTime
<
10
)
{
// if (dowMin < 10) {
hour
=
"0"
+
selectHourTime
;
// selectMin_dw = "0" + dowMin;
}
else
{
// } else {
hour
=
String
.
valueOf
(
selectHourTime
);
// selectMin_dw = String.valueOf(dowMin);
// }
//
// wheelMinute_dw.setSeletion(minuteList.indexOf(selectMin_dw));
}
}
});
wheelHour
.
setSeletion
(
hourList
.
indexOf
(
hour
));
//秒的选择
wheelSecond
.
setOnWheelViewListener
(
new
WheelView
.
OnWheelViewListener
()
{
//分钟
@Override
if
(
minute
.
startsWith
(
"0"
))
{
public
void
onSelected
(
int
selectedIndex
,
String
item
)
{
minute
=
minute
.
substring
(
1
);
if
(
StringUtils
.
isEmpty
(
item
))
{
int
indexSecond
=
secondList
.
indexOf
(
selectSec
);
wheelSecond
.
setSeletion
(
indexSecond
);
return
;
}
}
selectMinTime
=
Integer
.
parseInt
(
minute
);
Date
time
=
new
Date
();
if
(
dwMinute
.
startsWith
(
"0"
))
{
Calendar
calendar
=
Calendar
.
getInstance
();
dwMinute
=
dwMinute
.
substring
(
1
);
calendar
.
setTime
(
time
);
int
nowHour
=
calendar
.
get
(
Calendar
.
HOUR
);
//时(12小时制)
int
nowMinute
=
calendar
.
get
(
Calendar
.
MINUTE
);
//分
int
nowSecond
=
calendar
.
get
(
Calendar
.
SECOND
);
String
currentHour
;
if
(
selectHour
.
startsWith
(
"0"
))
{
currentHour
=
item
.
substring
(
1
);
}
else
{
currentHour
=
selectHour
;
}
}
Integer
currentSelectHour
=
Integer
.
valueOf
(
currentHour
);
dwMinTime
=
Integer
.
parseInt
(
dwMinute
);
String
currentMin
;
if
(
selectMin
.
startsWith
(
"0"
))
{
selectMinTime
=
selectMinTime
+
dwMinTime
;
currentMin
=
item
.
substring
(
1
);
if
(
selectMinTime
<
10
)
{
minute
=
"0"
+
selectMinTime
;
}
else
{
}
else
{
currentMin
=
selectMin
;
minute
=
String
.
valueOf
(
selectMinTime
)
;
}
}
Integer
currentSelectMin
=
Integer
.
valueOf
(
currentMin
);
wheelMinute
.
setSeletion
(
sixList
.
indexOf
(
minute
));
//当小时大于当前的时间
if
(
currentSelectHour
>=
nowHour
)
{
if
(
currentSelectMin
>
nowMinute
)
{
//秒
selectSec
=
item
;
if
(
second
.
startsWith
(
"0"
))
{
second
=
second
.
substring
(
1
);
}
}
selectSecTime
=
Integer
.
parseInt
(
second
);
if
(
dwSecond
.
startsWith
(
"0"
))
{
dwSecond
=
dwSecond
.
substring
(
1
);
}
dwSecTime
=
Integer
.
parseInt
(
dwSecond
);
if
(
currentSelectMin
==
nowMinute
)
{
String
sec
;
selectSecTime
=
selectSecTime
+
dwSecTime
;
if
(
item
.
startsWith
(
"0"
)
)
{
if
(
selectSecTime
<
10
)
{
sec
=
item
.
substring
(
1
)
;
second
=
"0"
+
selectSecTime
;
}
else
{
}
else
{
sec
=
item
;
second
=
String
.
valueOf
(
selectSecTime
)
;
}
}
Integer
selectSecTime
=
Integer
.
valueOf
(
sec
);
//计算秒
wheelSecond
.
setSeletion
(
sixList
.
indexOf
(
second
));
if
(
selectSecTime
<
nowSecond
)
{
int
indexSec
=
secondList
.
indexOf
(
selectMin
);
wheelSecond
.
setSeletion
(
indexSec
);
ToastUtils
.
show
(
"选择的时间不能小于当前时间"
);
}
else
{
selectMin
=
item
;
}
}
//
// int dowSec = selectSecTime - nowSecond;
@Override
// if (dowSec < 10) {
public
void
init
(
Bundle
savedInstanceState
)
{
// selectSec_dw = "0" + dowSec;
// } else {
wheelHour
.
setOnWheelViewListener
(
new
WheelView
.
OnWheelViewListener
()
{
// selectSec_dw = String.valueOf(dowSec);
@Override
// }
public
void
onSelected
(
int
selectedIndex
,
String
item
)
{
//
if
(
StringUtils
.
isEmpty
(
item
))
{
// wheelSecond_dw.setSeletion(secondList.indexOf(selectSec_dw));
//不能动
int
indexHour
=
hourList
.
indexOf
(
selectHour
);
wheelHour
.
setSeletion
(
indexHour
);
return
;
}
}
setDwTime
();
}
else
{
ToastUtils
.
show
(
"选择的时间不能小于当前时间"
);
}
}
});
wheelMinute
.
setOnWheelViewListener
(
new
WheelView
.
OnWheelViewListener
()
{
@Override
public
void
onSelected
(
int
selectedIndex
,
String
item
)
{
if
(
StringUtils
.
isEmpty
(
item
))
{
int
indexMinute
=
sixList
.
indexOf
(
selectMin
);
wheelMinute
.
setSeletion
(
indexMinute
);
return
;
}
setDwTime
();
}
}
});
});
wheelHour_dw
.
setOnWheelViewListener
(
new
WheelView
.
OnWheelViewListener
()
{
//秒的选择
wheelSecond
.
setOnWheelViewListener
(
new
WheelView
.
OnWheelViewListener
()
{
@Override
@Override
public
void
onSelected
(
int
selectedIndex
,
String
item
)
{
public
void
onSelected
(
int
selectedIndex
,
String
item
)
{
selectHour_dw
=
hourList
.
get
(
selectedIndex
);
if
(
StringUtils
.
isEmpty
(
item
))
{
int
indexSecond
=
sixList
.
indexOf
(
selectSec
);
wheelSecond
.
setSeletion
(
indexSecond
);
return
;
}
setDwTime
();
}
}
});
});
wheelHour_dw
.
setOnWheelViewListener
(
new
WheelView
.
OnWheelViewListener
()
{
@Override
public
void
onSelected
(
int
selectedIndex
,
String
item
)
{
setUpTime
();
}
});
wheelMinute_dw
.
setOnWheelViewListener
(
new
WheelView
.
OnWheelViewListener
()
{
wheelMinute_dw
.
setOnWheelViewListener
(
new
WheelView
.
OnWheelViewListener
()
{
@Override
@Override
public
void
onSelected
(
int
selectedIndex
,
String
item
)
{
public
void
onSelected
(
int
selectedIndex
,
String
item
)
{
se
lectMin_dw
=
minuteList
.
get
(
selectedIndex
);
se
tUpTime
(
);
}
}
});
});
...
@@ -297,56 +306,46 @@ public class SetTimeActivity extends BaseActivity {
...
@@ -297,56 +306,46 @@ public class SetTimeActivity extends BaseActivity {
wheelSecond_dw
.
setOnWheelViewListener
(
new
WheelView
.
OnWheelViewListener
()
{
wheelSecond_dw
.
setOnWheelViewListener
(
new
WheelView
.
OnWheelViewListener
()
{
@Override
@Override
public
void
onSelected
(
int
selectedIndex
,
String
item
)
{
public
void
onSelected
(
int
selectedIndex
,
String
item
)
{
se
lectSec_dw
=
secondList
.
get
(
selectedIndex
);
se
tUpTime
(
);
}
}
});
});
}
}
@Override
@Override
public
void
initData
()
{
public
void
initData
()
{
Date
time
=
new
Date
();
Date
time
=
new
Date
();
Calendar
calendar
=
Calendar
.
getInstance
();
int
hour
=
LocalDateUtils
.
getHour
(
time
);
calendar
.
setTime
(
time
);
int
minute
=
LocalDateUtils
.
getSecond
(
time
);
int
hour
=
calendar
.
get
(
Calendar
.
HOUR
);
//时(12小时制)
int
second
=
LocalDateUtils
.
getMinute
(
time
);
int
minute
=
calendar
.
get
(
Calendar
.
MINUTE
);
//分
int
second
=
calendar
.
get
(
Calendar
.
SECOND
);
int
currTime
=
LocalDateUtils
.
getHour
(
time
);
if
(
currTime
>
12
)
{
amOrPm
=
1
;
}
else
{
amOrPm
=
0
;
}
hourList
.
clear
();
minuteList
.
clear
();
secondList
.
clear
();
amPmList
.
add
(
"AM"
);
hourList
.
clear
(
);
amPmList
.
add
(
"PM"
);
sixList
.
clear
(
);
hourList
.
add
(
"00"
);
hourList
.
add
(
"00"
);
for
(
int
i
=
1
;
i
<=
12
;
i
++)
{
for
(
int
i
=
1
;
i
<=
24
;
i
++)
{
if
(
i
<
10
)
{
if
(
i
<
10
)
{
hourList
.
add
(
"0"
+
i
);
hourList
.
add
(
"0"
+
i
);
}
else
{
}
else
{
hourList
.
add
(
String
.
valueOf
(
i
));
hourList
.
add
(
String
.
valueOf
(
i
));
}
}
}
}
for
(
int
i
=
0
;
i
<=
59
;
i
++)
{
for
(
int
i
=
0
;
i
<=
59
;
i
++)
{
if
(
i
<
10
)
{
if
(
i
<
10
)
{
minuteList
.
add
(
"0"
+
i
);
sixList
.
add
(
"0"
+
i
);
secondList
.
add
(
"0"
+
i
);
}
else
{
}
else
{
minute
List
.
add
(
String
.
valueOf
(
i
));
six
List
.
add
(
String
.
valueOf
(
i
));
secondList
.
add
(
String
.
valueOf
(
i
));
}
}
}
for
(
int
i
=
1
;
i
<=
16
;
i
++)
{
if
(
i
<
10
)
{
selectTime
.
add
(
"0"
+
i
);
}
else
{
selectTime
.
add
(
String
.
valueOf
(
i
));
}
}
}
///时////
///时////
...
@@ -362,47 +361,42 @@ public class SetTimeActivity extends BaseActivity {
...
@@ -362,47 +361,42 @@ public class SetTimeActivity extends BaseActivity {
///分////
///分////
wheelMinute
.
setOffset
(
3
);
// 对话框中当前项上面和下面的项数
wheelMinute
.
setOffset
(
3
);
// 对话框中当前项上面和下面的项数
wheelMinute
.
setItems
(
minute
List
);
// 设置数据源
wheelMinute
.
setItems
(
six
List
);
// 设置数据源
if
(
minute
<
10
)
{
if
(
minute
<
10
)
{
selectMin
=
"0"
+
minute
;
selectMin
=
"0"
+
minute
;
}
else
{
}
else
{
selectMin
=
String
.
valueOf
(
minute
);
selectMin
=
String
.
valueOf
(
minute
);
}
}
int
indexMinute
=
minute
List
.
indexOf
(
selectMin
);
int
indexMinute
=
six
List
.
indexOf
(
selectMin
);
wheelMinute
.
setSeletion
(
indexMinute
);
// 默认选中第三项
wheelMinute
.
setSeletion
(
indexMinute
);
// 默认选中第三项
///秒////
///秒////
wheelSecond
.
setOffset
(
3
);
wheelSecond
.
setOffset
(
3
);
wheelSecond
.
setItems
(
s
econd
List
);
// 设置数据源
wheelSecond
.
setItems
(
s
ix
List
);
// 设置数据源
if
(
second
<
10
)
{
if
(
second
<
10
)
{
selectSec
=
"0"
+
second
;
selectSec
=
"0"
+
second
;
}
else
{
}
else
{
selectSec
=
String
.
valueOf
(
second
);
selectSec
=
String
.
valueOf
(
second
);
}
}
int
indexSecond
=
s
econd
List
.
indexOf
(
selectSec
);
int
indexSecond
=
s
ix
List
.
indexOf
(
selectSec
);
wheelSecond
.
setSeletion
(
indexSecond
);
wheelSecond
.
setSeletion
(
indexSecond
);
wheelAmPm
.
setOffset
(
2
);
// 对话框中当前项上面和下面的项数
wheelAmPm
.
setItems
(
amPmList
);
// 设置数据源
wheelAmPm
.
setSeletion
(
amOrPm
);
// 默认选中第三项
/////////下////////
/////////下////////
///时////
///时////
wheelHour_dw
.
setOffset
(
3
);
wheelHour_dw
.
setOffset
(
3
);
wheelHour_dw
.
setItems
(
hourList
);
wheelHour_dw
.
setItems
(
selectTime
);
wheelHour_dw
.
setSeletion
(
0
);
wheelHour_dw
.
setSeletion
(
0
);
///分////
///分////
wheelMinute_dw
.
setOffset
(
3
);
// 对话框中当前项上面和下面的项数
wheelMinute_dw
.
setOffset
(
3
);
// 对话框中当前项上面和下面的项数
wheelMinute_dw
.
setItems
(
minute
List
);
// 设置数据源
wheelMinute_dw
.
setItems
(
six
List
);
// 设置数据源
wheelMinute_dw
.
setSeletion
(
0
);
// 默认选中第三项
wheelMinute_dw
.
setSeletion
(
0
);
// 默认选中第三项
///秒////
///秒////
wheelSecond_dw
.
setOffset
(
3
);
wheelSecond_dw
.
setOffset
(
3
);
wheelSecond_dw
.
setItems
(
s
econd
List
);
wheelSecond_dw
.
setItems
(
s
ix
List
);
wheelSecond_dw
.
setSeletion
(
0
);
wheelSecond_dw
.
setSeletion
(
0
);
}
}
...
@@ -426,6 +420,10 @@ public class SetTimeActivity extends BaseActivity {
...
@@ -426,6 +420,10 @@ public class SetTimeActivity extends BaseActivity {
ToastUtils
.
show
(
"请打开蓝牙"
);
ToastUtils
.
show
(
"请打开蓝牙"
);
return
;
return
;
}
}
String
selectHour_dw
=
wheelHour_dw
.
getSeletedItem
();
String
selectMin_dw
=
wheelMinute_dw
.
getSeletedItem
();
String
selectSec_dw
=
wheelSecond_dw
.
getSeletedItem
();
if
(
TextUtils
.
isEmpty
(
selectHour_dw
))
{
if
(
TextUtils
.
isEmpty
(
selectHour_dw
))
{
hour
=
0
;
hour
=
0
;
}
else
if
(
selectHour_dw
.
startsWith
(
"0"
))
{
}
else
if
(
selectHour_dw
.
startsWith
(
"0"
))
{
...
...
app/src/main/java/com/example/blu/toys/ble/BlePlay.java
View file @
7b0ef205
...
@@ -47,6 +47,15 @@ public class BlePlay {
...
@@ -47,6 +47,15 @@ public class BlePlay {
private
SpUtils
mSpUtils
;
private
SpUtils
mSpUtils
;
public
List
<
BleDevice
>
getScanResultList
()
{
return
scanResultList
;
}
public
void
setScanResultList
(
List
<
BleDevice
>
scanResultList
)
{
this
.
scanResultList
=
scanResultList
;
}
private
List
<
BleDevice
>
scanResultList
;
public
static
BlePlay
getInstance
()
{
public
static
BlePlay
getInstance
()
{
if
(
instance
==
null
)
{
if
(
instance
==
null
)
{
...
@@ -99,7 +108,8 @@ public class BlePlay {
...
@@ -99,7 +108,8 @@ public class BlePlay {
@Override
@Override
public
void
onScanFinished
(
List
<
BleDevice
>
scanResultList
)
{
public
void
onScanFinished
(
List
<
BleDevice
>
scanResultList
)
{
LogUtils
.
e
(
"扫描介素获取设备列表"
);
LogUtils
.
e
(
"扫描介素获取设备列表"
);
EventBus
.
getDefault
().
postSticky
(
scanResultList
);
setScanResultList
(
scanResultList
);
EventBus
.
getDefault
().
post
(
scanResultList
);
}
}
});
});
}
}
...
...
app/src/main/java/com/example/blu/toys/ble/agreement/TrafficLightBean.java
View file @
7b0ef205
...
@@ -77,7 +77,8 @@ public class TrafficLightBean {
...
@@ -77,7 +77,8 @@ public class TrafficLightBean {
this
.
cmd
=
BitOperator
.
integerTo1Byte
(
protocolNo
);
this
.
cmd
=
BitOperator
.
integerTo1Byte
(
protocolNo
);
this
.
suspendAndContinue
=
BitOperator
.
integerTo1Byte
(
suspendAndContinue
);
this
.
suspendAndContinue
=
BitOperator
.
integerTo1Byte
(
suspendAndContinue
);
this
.
timeRemaining
=
BitOperator
.
integerTo2Bytes
(
timeRemaining
);
System
.
out
.
println
(
"传入的剩余时间:"
+
timeRemaining
);
this
.
timeRemaining
=
toLH
(
timeRemaining
);
//BitOperator.integerTo2Bytes();
this
.
brightness
=
BitOperator
.
integerTo1Byte
(
brightness
);
this
.
brightness
=
BitOperator
.
integerTo1Byte
(
brightness
);
this
.
openSoundNo
=
BitOperator
.
integerTo1Byte
(
openSoundNo
);
this
.
openSoundNo
=
BitOperator
.
integerTo1Byte
(
openSoundNo
);
this
.
closeSoundNo
=
BitOperator
.
integerTo1Byte
(
closeSoundNo
);
this
.
closeSoundNo
=
BitOperator
.
integerTo1Byte
(
closeSoundNo
);
...
@@ -106,6 +107,18 @@ public class TrafficLightBean {
...
@@ -106,6 +107,18 @@ public class TrafficLightBean {
}
}
/**
* int 转换小端
* @param n
* @return
*/
public
static
byte
[]
toLH
(
int
n
)
{
byte
[]
b
=
new
byte
[
2
];
b
[
0
]
=
(
byte
)
(
n
&
0xff
);
b
[
1
]
=
(
byte
)
(
n
>>
8
&
0xff
);
return
b
;
}
public
byte
[]
toByte
(){
public
byte
[]
toByte
(){
//数据要加密的
//数据要加密的
...
...
app/src/main/java/com/example/blu/toys/utils/LocalDateUtils.java
View file @
7b0ef205
package
com
.
example
.
blu
.
toys
.
utils
;
package
com
.
example
.
blu
.
toys
.
utils
;
import
java.text.DateFormat
;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.DayOfWeek
;
import
java.time.DayOfWeek
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
...
@@ -158,6 +160,16 @@ public class LocalDateUtils {
...
@@ -158,6 +160,16 @@ public class LocalDateUtils {
return
format
(
LocalTime
.
now
(),
TIME_PATTERN
);
return
format
(
LocalTime
.
now
(),
TIME_PATTERN
);
}
}
public
static
Date
getDateTime
(
String
time
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
TIME_PATTERN
);
//根据自己情况
try
{
return
sdf
.
parse
(
time
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
/**
* 获取当前星期字符串.
* 获取当前星期字符串.
*
*
...
@@ -623,9 +635,6 @@ public class LocalDateUtils {
...
@@ -623,9 +635,6 @@ public class LocalDateUtils {
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
getLocalDateTimeStr
());
System
.
out
.
println
(
getLocalDateTimeStr
());
System
.
out
.
println
(
getLocalDateStr
());
System
.
out
.
println
(
getLocalDateStr
());
...
...
app/src/main/res/layout/activity_set_time.xml
View file @
7b0ef205
...
@@ -80,8 +80,7 @@
...
@@ -80,8 +80,7 @@
<RelativeLayout
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/dp_75"
android:layout_height=
"@dimen/dp_75"
android:background=
"@drawable/black_thumb"
android:background=
"@drawable/black_thumb"
>
>
<LinearLayout
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -132,12 +131,12 @@
...
@@ -132,12 +131,12 @@
android:layout_gravity=
"center_vertical"
/>
android:layout_gravity=
"center_vertical"
/>
<com.example.blu.toys.view.WheelView
<!-- <com.example.blu.toys.view.WheelView-->
android:id=
"@+id/wheel_am_pm"
<!-- android:id="@+id/wheel_am_pm"-->
android:layout_width=
"wrap_content"
<!-- android:layout_width="wrap_content"-->
android:layout_height=
"wrap_content"
<!-- android:layout_height="wrap_content"-->
android:layout_gravity=
"center_vertical"
<!-- android:layout_gravity="center_vertical"-->
android:layout_marginLeft=
"20dp"
/
>
<!-- android:layout_marginLeft="20dp" />--
>
</LinearLayout>
</LinearLayout>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment