Commit d530dc61 by chengchong

返回问题

parent 15324386
......@@ -19,7 +19,6 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>
......
<?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="/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
<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>
\ No newline at end of file
<?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="/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
<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>
\ No newline at end of file
<?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="/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
<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>
\ No newline at end of file
<?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="/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
<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>
\ No newline at end of file
......@@ -6,21 +6,21 @@
6
7 <uses-sdk
8 android:minSdkVersion="14"
8-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
8-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
9 android:targetSdkVersion="30" />
9-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
9-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
10
11 <uses-permission android:name="android.permission.BLUETOOTH" />
11-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:5-68
11-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:22-65
11-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:5-68
11-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:22-65
12 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
12-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:5-74
12-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:22-71
12-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:5-74
12-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:22-71
13 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
13-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:5-81
13-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:22-78
13-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:5-81
13-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:22-78
14 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
14-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:5-79
14-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:22-76
14-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:5-79
14-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:22-76
15
16</manifest>
-- Merging decision tree log ---
manifest
ADDED from /Users/hanfeihu/助利帮/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 /Users/hanfeihu/助利帮/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 /Users/hanfeihu/助利帮/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 /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
ADDED from D:\androidProject\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 D:\androidProject\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 D:\androidProject\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 D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12
package
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:2:5-30
INJECTED from /Users/hanfeihu/助利帮/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:2:5-30
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
android:versionName
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
android:versionCode
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
xmlns:android
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:11-69
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:11-69
uses-permission#android.permission.BLUETOOTH
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:5-68
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:5-68
android:name
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:22-65
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:22-65
uses-permission#android.permission.BLUETOOTH_ADMIN
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:5-74
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:5-74
android:name
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:22-71
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:22-71
uses-permission#android.permission.ACCESS_COARSE_LOCATION
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:5-81
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:5-81
android:name
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:22-78
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:22-78
uses-permission#android.permission.ACCESS_FINE_LOCATION
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:5-79
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:5-79
android:name
ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:22-76
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:22-76
uses-sdk
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml reason: use-sdk injection requested
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from /Users/hanfeihu/助利帮/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 reason: use-sdk injection requested
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
android:targetSdkVersion
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from /Users/hanfeihu/助利帮/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
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
android:minSdkVersion
INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from /Users/hanfeihu/助利帮/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
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml
......@@ -289,7 +289,6 @@ public class BleManager {
* @param callback
*/
public void scan(BleScanCallback callback) {
try {
if (callback == null) {
throw new IllegalArgumentException("BleScanCallback can not be Null!");
......
{
"version": 1,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.example.blu.toys",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"properties": [],
"versionCode": 1,
"versionName": "1.0",
"enabled": true,
"outputFile": "app-release.apk"
}
]
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import android.os.Handler;
import com.example.blu.toys.activity.AddDeviceActivity;
import com.example.blu.toys.activity.BaseActivity;
import com.example.blu.toys.app.AppManager;
public class MainActivity extends BaseActivity {
......@@ -18,7 +19,7 @@ public class MainActivity extends BaseActivity {
public void init(Bundle savedInstanceState) {
new Handler().postDelayed(() -> {
goActivity(AddDeviceActivity.class);
finish();
AppManager.getInstance().finishActivity();
}, 1000); //延时1s执行
}
......
......@@ -3,11 +3,14 @@ package com.example.blu.toys.activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.Toast;
import androidx.appcompat.widget.AppCompatImageView;
import com.example.blu.toys.MainActivity;
import com.example.blu.toys.R;
import com.example.blu.toys.app.AppManager;
import butterknife.BindView;
import butterknife.OnClick;
......@@ -16,6 +19,8 @@ public class AddDeviceActivity extends BaseActivity {
@BindView(R.id.go_search_ble)
AppCompatImageView goSearchBle;
//退出时的时间
private long mExitTime;
@Override
public int getLayout() {
......@@ -32,10 +37,24 @@ public class AddDeviceActivity extends BaseActivity {
}
//对返回键进行监听
@Override
public void onBackPressed() {
this.finish();
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
exit();
return true;
}
return super.onKeyDown(keyCode, event);
}
//退出方法
private void exit() {
if ((System.currentTimeMillis() - mExitTime) > 2000) {
Toast.makeText(AddDeviceActivity.this, "再按一次退出应用", Toast.LENGTH_SHORT).show();
mExitTime = System.currentTimeMillis();
} else {
//用户退出处理
AppManager.getInstance().exitApp();
}
}
@OnClick(R.id.go_search_ble)
......
......@@ -10,8 +10,11 @@ import android.widget.ImageView;
import androidx.annotation.RequiresApi;
import androidx.appcompat.widget.AppCompatImageView;
import com.blankj.utilcode.util.LogUtils;
import com.clj.fastble.BleManager;
import com.clj.fastble.data.BleDevice;
import com.example.blu.toys.R;
import com.example.blu.toys.app.AppManager;
import com.example.blu.toys.ble.BlePlay;
import org.greenrobot.eventbus.EventBus;
......@@ -27,68 +30,75 @@ import butterknife.OnClick;
public class SearchingActivity extends BaseActivity {
@BindView(R.id.iv_beecartoon)
ImageView ivBeecartoon;
@BindView(R.id.go_search_ble)
AppCompatImageView goSearchBle;
@BindView(R.id.go_search_ble_1)
AppCompatImageView goSearchBle1;
@BindView(R.id.go_search_ble_2)
AppCompatImageView goSearchBle2;
@Override
public int getLayout() {
return R.layout.activity_searching;
}
@Override
public void init(Bundle savedInstanceState) {
EventBus.getDefault().register(this);
}
@Override
public void initData() {
BlePlay.getInstance().scanBle();
}
@RequiresApi(api = Build.VERSION_CODES.N)
@Subscribe(threadMode = ThreadMode.MAIN)
public void GoDeviceListPage(List<BleDevice> bleDevices) {
@BindView(R.id.iv_beecartoon)
ImageView ivBeecartoon;
@BindView(R.id.go_search_ble)
AppCompatImageView goSearchBle;
@BindView(R.id.go_search_ble_1)
AppCompatImageView goSearchBle1;
@BindView(R.id.go_search_ble_2)
AppCompatImageView goSearchBle2;
boolean isBreak;
@Override
public int getLayout() {
return R.layout.activity_searching;
}
@Override
public void init(Bundle savedInstanceState) {
EventBus.getDefault().register(this);
Animation animation = AnimationUtils.loadAnimation(this, R.anim.translate_anim);
ivBeecartoon.startAnimation(animation);
goSearchBle.setImageDrawable(this.getResources().getDrawable(R.drawable.search_bg));
Animation animation1 = AnimationUtils.loadAnimation(this, R.anim.search_anim);
goSearchBle.startAnimation(animation1);
new Handler().postDelayed(new Runnable() {
public void run() {
Animation animation2 = AnimationUtils.loadAnimation(SearchingActivity.this, R.anim.search_anim);
goSearchBle1.setImageDrawable(SearchingActivity.this.getResources().getDrawable(R.drawable.search_bg));
goSearchBle1.startAnimation(animation2);
}
}, 700);
new Handler().postDelayed(new Runnable() {
public void run() {
Animation animation3 = AnimationUtils.loadAnimation(SearchingActivity.this, R.anim.search_anim);
goSearchBle2.setImageDrawable(SearchingActivity.this.getResources().getDrawable(R.drawable.search_bg));
goSearchBle2.startAnimation(animation3);
}
}, 1400);
}
@Override
public void initData() {
BlePlay.getInstance().scanBle();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void GoDeviceListPage(String msg) {
if (isBreak) {
return;
}
goActivity(SelectDeviceActivity.class);
}
@OnClick(R.id.back_but)
public void onViewClicked() {
finish();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
Animation animation = AnimationUtils.loadAnimation(this, R.anim.translate_anim);
ivBeecartoon.startAnimation(animation);
goSearchBle.setImageDrawable(this.getResources().getDrawable(R.drawable.search_bg));
Animation animation1 = AnimationUtils.loadAnimation(this, R.anim.search_anim);
goSearchBle.startAnimation(animation1);
new Handler().postDelayed(new Runnable() {
public void run() {
Animation animation2 = AnimationUtils.loadAnimation(SearchingActivity.this, R.anim.search_anim);
goSearchBle1.setImageDrawable(SearchingActivity.this.getResources().getDrawable(R.drawable.search_bg));
goSearchBle1.startAnimation(animation2);
}
}, 700);
new Handler().postDelayed(new Runnable() {
public void run() {
Animation animation3 = AnimationUtils.loadAnimation(SearchingActivity.this, R.anim.search_anim);
goSearchBle2.setImageDrawable(SearchingActivity.this.getResources().getDrawable(R.drawable.search_bg));
goSearchBle2.startAnimation(animation3);
}
}, 1400);
}
AppManager.getInstance().finishActivity();
}
@OnClick(R.id.back_but)
public void onViewClicked() {
isBreak = true;
BlePlay.getInstance().canceScan();
AppManager.getInstance().finishActivity();
}
@Override
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
}
}
\ No newline at end of file
package com.example.blu.toys.activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
import com.blankj.utilcode.util.CollectionUtils;
import com.blankj.utilcode.util.LogUtils;
import com.clj.fastble.data.BleDevice;
import com.example.blu.toys.R;
import com.example.blu.toys.adapter.BleDeviceAdapter;
import com.example.blu.toys.app.AppManager;
import com.example.blu.toys.ble.BlePlay;
import com.example.blu.toys.view.TypefaceTextView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
......@@ -27,6 +28,8 @@ public class SelectDeviceActivity extends BaseActivity {
@BindView(R.id.recyclerView)
RecyclerView mRecyclerView;
@BindView(R.id.device_not_found)
TypefaceTextView mDeviceNotFound;
BleDeviceAdapter bleDeviceAdapter;
private List<BleDevice> bleDevices;
......@@ -60,6 +63,7 @@ public class SelectDeviceActivity extends BaseActivity {
public void showBleDevices() {
List<BleDevice> bles = BlePlay.getInstance().getScanResultList();
if (CollectionUtils.isEmpty(bles)) {
mDeviceNotFound.setVisibility(View.VISIBLE);
return;
}
......@@ -71,6 +75,9 @@ public class SelectDeviceActivity extends BaseActivity {
bleDevices.add(bleDevice);
}
}
if (CollectionUtils.isEmpty(bleDevices)) {
mDeviceNotFound.setVisibility(View.VISIBLE);
}
if (bleDeviceAdapter != null) {
bleDeviceAdapter.notifyDataSetChanged();
}
......@@ -79,22 +86,20 @@ public class SelectDeviceActivity extends BaseActivity {
@Subscribe(threadMode = ThreadMode.MAIN)
public void connDevices(BleDevice ble) {
LogUtils.e("连接 成功");
goActivity(SetTimeActivity.class);
AppManager.getInstance().finishActivity();
}
@OnClick(R.id.back_but)
public void onViewClicked() {
Intent intent = new Intent(SelectDeviceActivity.this, AddDeviceActivity.class);
startActivity(intent);
AppManager.getInstance().finishActivity();
}
@Override
public void onBackPressed() {
Intent intent = new Intent(SelectDeviceActivity.this, AddDeviceActivity.class);
startActivity(intent);
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import android.widget.SeekBar;
import android.widget.Switch;
import com.example.blu.toys.R;
import com.example.blu.toys.app.AppManager;
import com.example.blu.toys.utils.SpUtils;
import com.example.blu.toys.view.TypefaceTextView;
......@@ -40,9 +41,18 @@ public class SelectTimerActivity extends BaseActivity {
public void init(Bundle savedInstanceState) {
SpUtils spUtils = SpUtils.getSpUtils(this);
// spUtils.putSPValue("close", 1);
// spUtils.putSPValue("open", 10);
spUtils.putSPValue("brightness", 50);
spUtils.getSPValue("close",1);
spUtils.getSPValue("open",10);
int alarm = spUtils.getSPValue("alarm", 1);
int green = spUtils.getSPValue("green", 1);
int brightness = spUtils.getSPValue("brightness", 50);
//数据回显
alarmSwitch.setChecked(alarm == 1 ? true : false);
greenSwitch.setChecked(green == 1 ? true : false);
brightnessBar.setProgress(brightness);
alarmSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
......@@ -92,6 +102,6 @@ public class SelectTimerActivity extends BaseActivity {
@OnClick(R.id.back_but)
public void onViewClicked() {
finish();
AppManager.getInstance().finishActivity();
}
}
\ No newline at end of file
......@@ -15,6 +15,7 @@ import com.clj.fastble.callback.BleWriteCallback;
import com.clj.fastble.data.BleDevice;
import com.clj.fastble.exception.BleException;
import com.example.blu.toys.R;
import com.example.blu.toys.app.AppManager;
import com.example.blu.toys.ble.BlePlay;
import com.example.blu.toys.ble.agreement.TrafficLightBean;
import com.example.blu.toys.utils.LocalDateUtils;
......@@ -39,11 +40,11 @@ public class SetTimeActivity extends BaseActivity {
@BindView(R.id.wheel_hour) //时
WheelView wheelHour;
WheelView wheelHour;
@BindView(R.id.wheel_minute)//分
WheelView wheelMinute;
WheelView wheelMinute;
@BindView(R.id.wheel_second)//秒
WheelView wheelSecond;
WheelView wheelSecond;
// @BindView(R.id.wheel_am_pm)
// WheelView wheelAmPm;
// amPmList.add("AM");
......@@ -71,8 +72,6 @@ public class SetTimeActivity extends BaseActivity {
ImageView mImageView03;
private ArrayList<String> hourList = new ArrayList<>();
private ArrayList<String> sixList = new ArrayList<>();
private ArrayList<String> selectTime = new ArrayList<>();
......@@ -93,8 +92,8 @@ public class SetTimeActivity extends BaseActivity {
return R.layout.activity_set_time;
}
private TimeBean getBottomTime(){
TimeBean timeBean=new TimeBean();
private TimeBean getBottomTime() {
TimeBean timeBean = new TimeBean();
String hour = wheelHour_dw.getSeletedItem();
......@@ -108,7 +107,7 @@ public class SetTimeActivity extends BaseActivity {
//设置上面的时间
TimeBean showTime= TimeUtil.getTimeBeanBySecond(Long.valueOf(timeBean.getTotalSecond()+getNowTotalSecond()));
TimeBean showTime = TimeUtil.getTimeBeanBySecond(Long.valueOf(timeBean.getTotalSecond() + getNowTotalSecond()));
showTime.toTime();
//设置上面的时间
wheelHour.setSeletion(showTime.getmHour());
......@@ -116,21 +115,20 @@ public class SetTimeActivity extends BaseActivity {
wheelSecond.setSeletion(showTime.getmSecond());
return timeBean;
}
public int getNowTotalSecond(){
public int getNowTotalSecond() {
Calendar cal = Calendar.getInstance();
int hour1=cal.get(Calendar.HOUR_OF_DAY);//小时
int minute2=cal.get(Calendar.MINUTE);//分
int second3=cal.get(Calendar.SECOND);//秒
return hour1*3600+minute2*60+second3;
int hour1 = cal.get(Calendar.HOUR_OF_DAY);//小时
int minute2 = cal.get(Calendar.MINUTE);//分
int second3 = cal.get(Calendar.SECOND);//秒
return hour1 * 3600 + minute2 * 60 + second3;
}
private TimeBean getTopTime(){
TimeBean timeBean=new TimeBean();
private TimeBean getTopTime() {
TimeBean timeBean = new TimeBean();
String hour = wheelHour.getSeletedItem();
......@@ -141,15 +139,15 @@ public class SetTimeActivity extends BaseActivity {
timeBean.setmHour(Integer.valueOf(hour));
timeBean.toTime();
int nowTotalSecond= getNowTotalSecond();
if(nowTotalSecond>timeBean.getTotalSecond()){
int nowTotalSecond = getNowTotalSecond();
if (nowTotalSecond > timeBean.getTotalSecond()) {
wheelHour_dw.setSeletion(15);
wheelMinute_dw.setSeletion(59);
wheelSecond_dw.setSeletion(59);
return timeBean;
}
int selectTotalSecond= timeBean.getTotalSecond();
TimeBean showTime= TimeUtil.getTimeBeanBySecond(Long.valueOf(selectTotalSecond-nowTotalSecond));
int selectTotalSecond = timeBean.getTotalSecond();
TimeBean showTime = TimeUtil.getTimeBeanBySecond(Long.valueOf(selectTotalSecond - nowTotalSecond));
//设置下面的时间
showTime.toTime();
//设置上面的时间
......@@ -160,7 +158,6 @@ public class SetTimeActivity extends BaseActivity {
}
@Override
public void init(Bundle savedInstanceState) {
......@@ -340,45 +337,31 @@ public class SetTimeActivity extends BaseActivity {
}
@OnClick({R.id.settings})
public void settingsClick(){
Intent intent = new Intent(SetTimeActivity.this, SelectTimerActivity.class);
startActivity(intent);
}
@OnClick({R.id.shop})
public void shopClick(){
Uri uri = Uri.parse("http://stoplightgolight.com/product/stoplight-golight/");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
@OnClick({R.id.rate})
public void rateClick(){
Uri uri = Uri.parse("http://stoplightgolight.com/product/stoplight-golight/");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
@Override
public void onBackPressed() {
BlePlay.getInstance().closeBle();
Intent intent = new Intent(SetTimeActivity.this, SelectDeviceActivity.class);
startActivity(intent);
AppManager.getInstance().finishActivity();
}
@OnClick({R.id.back_but, R.id.start_but})
@OnClick({R.id.back_but, R.id.start_but, R.id.settings, R.id.shop, R.id.rate})
public void onViewClicked(View view) {
Intent intent = null;
Uri uri = null;
switch (view.getId()) {
case R.id.settings:
intent = new Intent(SetTimeActivity.this, SelectTimerActivity.class);
startActivity(intent);
break;
case R.id.shop:
case R.id.rate:
uri = Uri.parse("http://stoplightgolight.com/product/stoplight-golight/");
intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
break;
case R.id.back_but:
BlePlay.getInstance().closeBle();
Intent intent = new Intent(SetTimeActivity.this, SelectDeviceActivity.class);
intent = new Intent(SetTimeActivity.this, SelectDeviceActivity.class);
startActivity(intent);
break;
case R.id.start_but:
......@@ -396,8 +379,8 @@ public class SetTimeActivity extends BaseActivity {
min = Integer.valueOf(selectMin_dw);
int time = Integer.valueOf(selectHour_dw) * 3600 +Integer.valueOf( selectMin_dw) * 60 + Integer.valueOf( selectSec_dw);
if(time==0){
int time = Integer.valueOf(selectHour_dw) * 3600 + Integer.valueOf(selectMin_dw) * 60 + Integer.valueOf(selectSec_dw);
if (time == 0) {
ToastUtils.show("请选择时间");
return;
}
......@@ -405,8 +388,6 @@ public class SetTimeActivity extends BaseActivity {
LogUtils.e("滚动了");
//转换成秒 0000000000000000
SpUtils spUtils = SpUtils.getSpUtils(SetTimeActivity.this);
......
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;
......@@ -10,59 +13,50 @@ import java.util.TimerTask;
*/
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++;
}
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++;
}
}
......@@ -40,8 +40,16 @@ public class App extends Application {
.enableLog(true)
.setReConnectCount(3, 5000)
.setMaxConnectCount(7)
.setSplitWriteNum(50000)
.setConnectOverTime(50000);
.setConnectOverTime(20000)
.setOperateTimeout(5000);
//
// BleManager.getInstance()
// .enableLog(true)
// .setReConnectCount(3, 5000)
// .setMaxConnectCount(7)
// .setSplitWriteNum(50000)
// .setConnectOverTime(50000).init(this);
SpUtils spUtils = SpUtils.getSpUtils(this);
spUtils.putSPValue("close",1);
......
......@@ -89,10 +89,10 @@ public class BlePlay {
* 扫描设备 30000
*/
public void scanBle() {
BleManager bleManager = BleManager.getInstance();
BleScanRuleConfig scanRuleConfig = new BleScanRuleConfig.Builder().setAutoConnect(false)
//.setServiceUuids(serviceIds)
.setScanTimeOut(5000).build();
BleManager.getInstance().initScanRule(scanRuleConfig);
bleManager.initScanRule(scanRuleConfig);
BleManager.getInstance().scan(new BleScanCallback() {
@Override
public void onScanStarted(boolean success) {
......@@ -108,8 +108,9 @@ public class BlePlay {
@Override
public void onScanFinished(List<BleDevice> scanResultList) {
LogUtils.e("扫描介素获取设备列表");
LogUtils.e("--------哈哈哈哈---");
setScanResultList(scanResultList);
EventBus.getDefault().post(scanResultList);
EventBus.getDefault().post("OK");
}
});
}
......
......@@ -44,6 +44,7 @@
android:text="Select your device"
android:textColor="@color/backer_back"
android:textSize="@dimen/sp_24"
app:typeface="@string/OCRAEXT"
android:textStyle="bold" />
......@@ -59,6 +60,7 @@
<com.example.blu.toys.view.TypefaceTextView
android:id="@+id/device_not_found"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/back_but"
......@@ -66,8 +68,9 @@
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/dp_14"
android:gravity="center"
android:visibility="invisible"
android:text="device not found"
android:textColor="#E07A3A"
android:textColor="@color/black"
android:textSize="@dimen/sp_14" />
</LinearLayout>
......
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