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
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
25 deletions
+53
-25
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
+0
-0
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
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.os.Bundle
;
...
...
@@ -38,7 +39,7 @@ public class SearchingActivity extends BaseActivity {
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
N
)
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
,
sticky
=
true
)
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
)
public
void
GoDeviceListPage
(
List
<
BleDevice
>
bleDevices
)
{
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 {
@Override
public
void
init
(
Bundle
savedInstanceState
)
{
EventBus
.
getDefault
().
register
(
this
);
}
@Override
public
void
initData
()
{
if
(
bleDevices
==
null
)
{
bleDevices
=
new
ArrayList
<>();
}
mRecyclerView
.
setLayoutManager
(
getLinearLayout
());
bleDeviceAdapter
=
new
BleDeviceAdapter
(
R
.
layout
.
ble_devices_item
,
bleDevices
);
mRecyclerView
.
setAdapter
(
bleDeviceAdapter
);
}
@Override
public
void
initData
()
{
bleDeviceAdapter
.
setOnItemClickListener
((
adapter
,
view
,
position
)
->
{
BleDevice
bleDevice
=
(
BleDevice
)
adapter
.
getItem
(
position
);
BlePlay
.
getInstance
().
connectedBleDevice
(
bleDevice
);
});
showBleDevices
();
}
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
,
sticky
=
true
)
public
void
showBleDevices
(
List
<
BleDevice
>
bles
)
{
public
void
showBleDevices
()
{
List
<
BleDevice
>
bles
=
BlePlay
.
getInstance
().
getScanResultList
();
if
(
CollectionUtils
.
isEmpty
(
bles
))
{
return
;
}
if
(
bleDevices
==
null
)
{
bleDevices
=
new
ArrayList
<>();
}
bleDevices
.
clear
();
for
(
int
i
=
0
;
i
<
bles
.
size
();
i
++)
{
BleDevice
bleDevice
=
bles
.
get
(
i
);
String
deviceName
=
bleDevice
.
getName
();
...
...
app/src/main/java/com/example/blu/toys/activity/SetTimeActivity.java
View file @
7b0ef205
This diff is collapsed.
Click to expand it.
app/src/main/java/com/example/blu/toys/ble/BlePlay.java
View file @
7b0ef205
...
...
@@ -47,6 +47,15 @@ public class BlePlay {
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
()
{
if
(
instance
==
null
)
{
...
...
@@ -99,7 +108,8 @@ public class BlePlay {
@Override
public
void
onScanFinished
(
List
<
BleDevice
>
scanResultList
)
{
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 {
this
.
cmd
=
BitOperator
.
integerTo1Byte
(
protocolNo
);
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
.
openSoundNo
=
BitOperator
.
integerTo1Byte
(
openSoundNo
);
this
.
closeSoundNo
=
BitOperator
.
integerTo1Byte
(
closeSoundNo
);
...
...
@@ -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
(){
//数据要加密的
...
...
app/src/main/java/com/example/blu/toys/utils/LocalDateUtils.java
View file @
7b0ef205
package
com
.
example
.
blu
.
toys
.
utils
;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.DayOfWeek
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
...
...
@@ -158,6 +160,16 @@ public class LocalDateUtils {
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 {
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
getLocalDateTimeStr
());
System
.
out
.
println
(
getLocalDateStr
());
...
...
app/src/main/res/layout/activity_set_time.xml
View file @
7b0ef205
...
...
@@ -80,8 +80,7 @@
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/dp_75"
android:background=
"@drawable/black_thumb"
>
android:background=
"@drawable/black_thumb"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
@@ -132,12 +131,12 @@
android:layout_gravity=
"center_vertical"
/>
<com.example.blu.toys.view.WheelView
android:id=
"@+id/wheel_am_pm"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginLeft=
"20dp"
/
>
<!-- <com.example.blu.toys.view.WheelView-->
<!-- android:id="@+id/wheel_am_pm"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="center_vertical"-->
<!-- android:layout_marginLeft="20dp" />--
>
</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