Commit 4f9b38e3 by 韩飞虎

修改了bug

parent 7b0ef205
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="1.8" />
</component>
</project>
\ No newline at end of file
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
</set> </set>
</option> </option>
<option name="resolveModulePerSourceSet" value="false" /> <option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings> </GradleProjectSettings>
</option> </option>
</component> </component>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\jniLibs"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\jniLibs"/></dataSet></merger> <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/jniLibs"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/jniLibs"/></dataSet></merger>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\shaders"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\shaders"/></dataSet></merger> <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/shaders"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/shaders"/></dataSet></merger>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\assets"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\intermediates\shader_assets\debug\out"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\assets"/></dataSet></merger> <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/assets"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/intermediates/shader_assets/debug/out"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/assets"/></dataSet></merger>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\res"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\generated\res\rs\debug"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\generated\res\resValues\debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main" generated-set="main$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\res"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\generated\res\rs\debug"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\generated\res\resValues\debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug" generated-set="debug$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\res"/></dataSet><mergedItems/></merger> <merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/res"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/generated/res/rs/debug"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/generated/res/resValues/debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main" generated-set="main$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/res"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/generated/res/rs/debug"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/generated/res/resValues/debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug" generated-set="debug$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/res"/></dataSet><mergedItems/></merger>
\ No newline at end of file \ No newline at end of file
...@@ -6,21 +6,21 @@ ...@@ -6,21 +6,21 @@
6 6
7 <uses-sdk 7 <uses-sdk
8 android:minSdkVersion="14" 8 android:minSdkVersion="14"
8-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml 8-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
9 android:targetSdkVersion="30" /> 9 android:targetSdkVersion="30" />
9-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml 9-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
10 10
11 <uses-permission android:name="android.permission.BLUETOOTH" /> 11 <uses-permission android:name="android.permission.BLUETOOTH" />
11-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:5-68 11-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:5-68
11-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:22-65 11-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:22-65
12 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> 12 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
12-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:5-74 12-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:5-74
12-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:22-71 12-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:22-71
13 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 13 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
13-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:5-81 13-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:5-81
13-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:22-78 13-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:22-78
14 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 14 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
14-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:5-79 14-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:5-79
14-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:22-76 14-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:22-76
15 15
16</manifest> 16</manifest>
-- Merging decision tree log --- -- Merging decision tree log ---
manifest manifest
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
package package
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:2:5-30 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:2:5-30
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
android:versionName android:versionName
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
android:versionCode android:versionCode
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
xmlns:android xmlns:android
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:11-69 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:11-69
uses-permission#android.permission.BLUETOOTH uses-permission#android.permission.BLUETOOTH
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:5-68 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:5-68
android:name android:name
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:22-65 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:22-65
uses-permission#android.permission.BLUETOOTH_ADMIN uses-permission#android.permission.BLUETOOTH_ADMIN
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:5-74 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:5-74
android:name android:name
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:22-71 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:22-71
uses-permission#android.permission.ACCESS_COARSE_LOCATION uses-permission#android.permission.ACCESS_COARSE_LOCATION
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:5-81 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:5-81
android:name android:name
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:22-78 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:22-78
uses-permission#android.permission.ACCESS_FINE_LOCATION uses-permission#android.permission.ACCESS_FINE_LOCATION
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:5-79 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:5-79
android:name android:name
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:22-76 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:22-76
uses-sdk uses-sdk
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml reason: use-sdk injection requested INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml reason: use-sdk injection requested
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
android:targetSdkVersion android:targetSdkVersion
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
android:minSdkVersion android:minSdkVersion
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
...@@ -5,19 +5,21 @@ import android.os.Bundle; ...@@ -5,19 +5,21 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.view.View; import android.view.View;
import android.widget.Toast;
import com.blankj.utilcode.util.LogUtils;
import com.clj.fastble.callback.BleWriteCallback; import com.clj.fastble.callback.BleWriteCallback;
import com.clj.fastble.exception.BleException; import com.clj.fastble.exception.BleException;
import com.example.blu.toys.R; import com.example.blu.toys.R;
import com.example.blu.toys.ble.BlePlay; import com.example.blu.toys.ble.BlePlay;
import com.example.blu.toys.ble.agreement.TrafficLightBean; import com.example.blu.toys.ble.agreement.TrafficLightBean;
import com.example.blu.toys.utils.SpUtils; import com.example.blu.toys.utils.SpUtils;
import com.example.blu.toys.utils.TimeBean;
import com.example.blu.toys.utils.TimeUtil;
import com.example.blu.toys.view.TypefaceTextView; import com.example.blu.toys.view.TypefaceTextView;
import com.example.blu.toys.view.WheelView;
import com.hjq.toast.ToastUtils; import com.hjq.toast.ToastUtils;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
public class PlayActivity extends BaseActivity { public class PlayActivity extends BaseActivity {
...@@ -26,62 +28,105 @@ public class PlayActivity extends BaseActivity { ...@@ -26,62 +28,105 @@ public class PlayActivity extends BaseActivity {
@BindView(R.id.task_time) @BindView(R.id.task_time)
TypefaceTextView typefaceTextView;//倒计时 TypefaceTextView typefaceTextView;//倒计时
private int suspendAndContinue=1;
private int mDay = 0; private int mDay = 0;
private int mHour = 0; private int mHour = 0;
private int mMin = 0; private int mMin = 0;
private int mSecond = 00;// 天 ,小时,分钟,秒 private int mSecond = 00;// 天 ,小时,分钟,秒
private boolean isRun = true; private boolean isRun = true;
private int totalSecond;
/**
* 不够位数的在前面补0,保留num的长度位数字
* @param code
* @return
*/
private String autoGenericCode(String code, int num) {
String result = "";
// 保留num的位数
// 0 代表前面补充0
// num 代表长度为4
// d 代表参数为正数型
result = String.format("%0" + num + "d", Integer.parseInt(code) + 1);
return result;
}
public static String addZeroForNum(String str,int strLength) {
int strLen =str.length();
if (strLen <strLength) {
while (strLen< strLength) {
StringBuffer sb = new StringBuffer();
sb.append("0").append(str);//左补0
// sb.append(str).append("0");//右补0
str= sb.toString();
strLen= str.length();
}
}
return str;
}
private Handler timeHandler = new Handler() { private Handler timeHandler = new Handler() {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
super.handleMessage(msg); super.handleMessage(msg);
if (msg.what == 1) { LogUtils.e("定时器在走111",msg.what,mHour,mMin,mSecond);
if(suspendAndContinue==1) {
computeTime(); computeTime();
typefaceTextView.setText(mHour + ":" + mHour + ":" + mSecond); String mHourStr = addZeroForNum(mHour + "", 2);
String mMinStr = addZeroForNum(mMin + "", 2);
String mSecondStr = addZeroForNum(mSecond + "", 2);
typefaceTextView.setText(mHourStr + ":" + mMinStr + ":" + mSecondStr);
sendBleData();
} }
} }
}; };
private TimerManager timerManager=new TimerManager(timeHandler);;
/** /**
* 开启倒计时 * 开启倒计时
*/ */
private void startRun() { private void startRun() {
new Thread(() -> {
while (isRun) {
try { timerManager.startTimer(0,1000);
Thread.sleep(1000); // sleep 1000ms
Message message = Message.obtain(); // new Thread(() -> {
message.what = 1; // while (isRun) {
timeHandler.sendMessage(message); // try {
} catch (Exception e) { // Thread.sleep(1000); // sleep 1000ms
e.printStackTrace(); // Message message = Message.obtain();
} // message.what = 1;
} // timeHandler.sendMessage(message);
}).start(); // } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }).start();
} }
/** /**
* 倒计时计算 * 倒计时计算
*/ */
private void computeTime() { private void computeTime() {
mSecond--; LogUtils.e("获取的时分秒",mHour,mMin,mSecond);
if (mSecond < 0) {
mMin--; totalSecond--;
mSecond = 59; TimeBean timeBean= TimeUtil.getTimeBeanBySecond(Long.valueOf(totalSecond));
if (mMin < 0) {
mMin = 59;
mHour--; mSecond = timeBean.getmSecond();
if (mHour < 0) { mHour = timeBean.getmHour();
// 倒计时结束 mMin = timeBean.getmMin();
mHour = 23;
mDay--;
}
}
}
} }
...@@ -96,6 +141,10 @@ public class PlayActivity extends BaseActivity { ...@@ -96,6 +141,10 @@ public class PlayActivity extends BaseActivity {
mHour = intent.getIntExtra("hour", 0); mHour = intent.getIntExtra("hour", 0);
mMin = intent.getIntExtra("min", 0); mMin = intent.getIntExtra("min", 0);
mSecond = intent.getIntExtra("second", 0); mSecond = intent.getIntExtra("second", 0);
totalSecond=mHour*3600+mMin*60+mSecond;
LogUtils.e("获取的时分秒",mHour,mMin,mSecond,totalSecond);
startRun(); startRun();
} }
...@@ -104,6 +153,37 @@ public class PlayActivity extends BaseActivity { ...@@ -104,6 +153,37 @@ public class PlayActivity extends BaseActivity {
} }
public void sendBleData(){
SpUtils spUtils = SpUtils.getSpUtils(PlayActivity.this);
int close = spUtils.getSPValue("close", 1);
int open = spUtils.getSPValue("open", 10);
int alarm = spUtils.getSPValue("alarm", 1);
int green = spUtils.getSPValue("green", 1);
int brightness = spUtils.getSPValue("brightness", 50);
TrafficLightBean ttt = new TrafficLightBean(2, suspendAndContinue,
totalSecond, brightness, open, close, green, alarm);
byte[] bytes12 = ttt.toByte();
BlePlay.getInstance().sendPause(bytes12, new BleWriteCallback() {
@Override
public void onWriteSuccess(int current, int total, byte[] justWrite) {
LogUtils.e("发送成功:"+suspendAndContinue);
//timerManager.cancelTimer();
}
@Override
public void onWriteFailure(BleException exception) {
}
});
}
@OnClick(R.id.back_but)
public void onViewClicked() {
timerManager.cancelTimer();
finish();
}
@OnClick({R.id.cancel_but, R.id.pause_but, R.id.resume_but}) @OnClick({R.id.cancel_but, R.id.pause_but, R.id.resume_but})
public void onViewClicked(View view) { public void onViewClicked(View view) {
...@@ -117,8 +197,7 @@ public class PlayActivity extends BaseActivity { ...@@ -117,8 +197,7 @@ public class PlayActivity extends BaseActivity {
switch (view.getId()) { switch (view.getId()) {
case R.id.cancel_but://取消 关机 case R.id.cancel_but://取消 关机
timerManager.cancelTimer();
TrafficLightBean trafficLightBean = new TrafficLightBean( TrafficLightBean trafficLightBean = new TrafficLightBean(
1, 0, 1, 0,
0, 0, 0, 0, 0, 0); 0, 0, 0, 0, 0, 0);
...@@ -127,27 +206,9 @@ public class PlayActivity extends BaseActivity { ...@@ -127,27 +206,9 @@ public class PlayActivity extends BaseActivity {
@Override @Override
public void onWriteSuccess(int current, int total, byte[] justWrite) { public void onWriteSuccess(int current, int total, byte[] justWrite) {
ToastUtils.show("关机-发送成功"); ToastUtils.show("关机-发送成功");
timeHandler.removeMessages(1);
}
@Override
public void onWriteFailure(BleException exception) {
}
});
finish();
case R.id.pause_but://暂停
int time = mHour * 360 + mMin * 60 + mSecond;
TrafficLightBean ttt = new TrafficLightBean(2, 0,
time, brightness, open, close, green, alarm);
byte[] bytes12 = ttt.toByte();
BlePlay.getInstance().sendPause(bytes12, new BleWriteCallback() {
@Override
public void onWriteSuccess(int current, int total, byte[] justWrite) {
ToastUtils.show("暂停-发送成功");
timeHandler.removeMessages(1);
} }
@Override @Override
...@@ -156,23 +217,31 @@ public class PlayActivity extends BaseActivity { ...@@ -156,23 +217,31 @@ public class PlayActivity extends BaseActivity {
} }
}); });
break;
case R.id.pause_but://暂停
// int time = mHour * 3600 + mMin * 60 + mSecond;
suspendAndContinue=0;
// TrafficLightBean ttt = new TrafficLightBean(2, suspendAndContinue,
// time, brightness, open, close, green, alarm);
// byte[] bytes12 = ttt.toByte();
// BlePlay.getInstance().sendPause(bytes12, new BleWriteCallback() {
// @Override
// public void onWriteSuccess(int current, int total, byte[] justWrite) {
//
// ToastUtils.show("暂停-发送成功");
//
// //timerManager.cancelTimer();
// }
//
// @Override
// public void onWriteFailure(BleException exception) {
//
// }
// });
break;
case R.id.resume_but://开始 case R.id.resume_but://开始
int hh = mHour * 360 + mMin * 60 + mSecond; suspendAndContinue=1;
TrafficLightBean tt = new TrafficLightBean(2, 1,
hh, brightness, open, close, green, alarm);
byte[] byte11 = tt.toByte();
BlePlay.getInstance().sendStard(byte11, new BleWriteCallback() {
@Override
public void onWriteSuccess(int current, int total, byte[] justWrite) {
startRun();
ToastUtils.show("开始-发送成功");
}
@Override
public void onWriteFailure(BleException exception) {
}
});
break; break;
} }
......
...@@ -447,7 +447,7 @@ public class SetTimeActivity extends BaseActivity { ...@@ -447,7 +447,7 @@ public class SetTimeActivity extends BaseActivity {
//转换成秒 0000000000000000 //转换成秒 0000000000000000
int time = hour * 360 + min * 60 + second; int time = hour * 3600 + min * 60 + second;
SpUtils spUtils = SpUtils.getSpUtils(SetTimeActivity.this); SpUtils spUtils = SpUtils.getSpUtils(SetTimeActivity.this);
int close = spUtils.getSPValue("close", 1); int close = spUtils.getSPValue("close", 1);
int open = spUtils.getSPValue("open", 10); int open = spUtils.getSPValue("open", 10);
......
package com.example.blu.toys.activity;
import android.os.Handler;
import android.os.Message;
import com.blankj.utilcode.util.LogUtils;
import java.util.Timer;
import java.util.TimerTask;
/**
* Created by MQL on 2016/8/12.
*/
public class TimerManager {
private Timer timer;
private TimerTask timerTask;
private Handler handler;
private int startCount=0;
private int countCount=0;
public TimerManager(final Handler handler){
this.handler = handler;
this.timer = new Timer();
this.timerTask = new TimerTask() {
@Override
public void run() {
if (handler != null){
LogUtils.e("定时器在走");
Message msg = new Message();
handler.sendMessage(msg);
}
}
};
}
/*
启动定时器, 在延时delay的时间后执行第一次,以后每隔period时间,执行一次
delay:第一次执行延时的时间
period:循环执行周期
*/
public void startTimer(long delay, long period){
try {
startCount++;
timer.schedule(timerTask, delay, period);
}catch (Exception e){
e.printStackTrace();
}
}
/*
取消定时器
*/
public void cancelTimer(){
timer.cancel();
timerTask.cancel();
countCount++;
}
}
package com.example.blu.toys.utils;
public class TimeBean {
private int mHour;
private int mMin;
private int mSecond;
private String[] tims;
public String[] getTims() {
return tims;
}
public void setTims(String[] tims) {
this.tims = tims;
}
public int getmHour() {
return mHour;
}
public void setmHour(int mHour) {
this.mHour = mHour;
}
public int getmMin() {
return mMin;
}
public void setmMin(int mMin) {
this.mMin = mMin;
}
public int getmSecond() {
return mSecond;
}
public void setmSecond(int mSecond) {
this.mSecond = mSecond;
}
}
package com.example.blu.toys.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TimeUtil {
public static String formatTime(long ms) {
int ss = 1000;
int mi = ss * 60;
int hh = mi * 60;
int dd = hh * 24;
long day = ms / dd;
long hour = (ms - day * dd) / hh;
long minute = (ms - day * dd - hour * hh) / mi;
long second = (ms - day * dd - hour * hh - minute * mi) / ss;
long milliSecond = ms - day * dd - hour * hh - minute * mi - second * ss;
String strHour = hour < 10 ? "0" + hour : "" + hour;//小时
String strMinute = minute < 10 ? "0" + minute : "" + minute;//分钟
String strSecond = second < 10 ? "0" + second : "" + second;//秒
String strMilliSecond = milliSecond < 10 ? "0" + milliSecond : "" + milliSecond;//毫秒
strMilliSecond = milliSecond < 100 ? "0" + strMilliSecond : "" + strMilliSecond;
return strHour+":"+strMinute + " : " + strSecond+","+strMilliSecond ;
}
public static TimeBean getTimeBeanBySecond(Long second){
String time= formatTime(second*1000);
TimeBean timeBean=new TimeBean();
String[] tims= time.split(":");
timeBean.setTims(tims);
timeBean.setmHour(Integer.valueOf(tims[0].trim()));
timeBean.setmMin(Integer.valueOf(tims[1].trim()));
timeBean.setmSecond(Integer.valueOf(tims[2].split(",")[0].trim()));
return timeBean;
}
public static void main(String[] args) {
System.out.println(Integer.valueOf("00"));
TimeBean timeBean= getTimeBeanBySecond(60l);
System.out.printf( timeBean.getmHour()+":"+ timeBean.getmMin()+":"+timeBean.getmSecond());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment