From 957b8e9d4bc63524dad27c2f8458856da0bf5c06 Mon Sep 17 00:00:00 2001 From: 张海江 <181069201@qq.com> Date: Mon, 07 Aug 2017 13:20:28 +0800 Subject: [PATCH] 提交代码 --- app/src/main/java/com/moral/yunfushao/MainActivity.java | 74 ++++++++++++++++++++++++++++++++----- 1 files changed, 64 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/moral/yunfushao/MainActivity.java b/app/src/main/java/com/moral/yunfushao/MainActivity.java index ccbb4d1..386bb84 100644 --- a/app/src/main/java/com/moral/yunfushao/MainActivity.java +++ b/app/src/main/java/com/moral/yunfushao/MainActivity.java @@ -6,7 +6,6 @@ import android.content.Intent; import android.content.ServiceConnection; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.os.Looper; @@ -118,12 +117,13 @@ @Override protected void initListener() { - +// registerBoradcastReceiver(); +// bleHeart(); } @Override protected void initData() { -// prepare(); + prepare(); if(MainApp.theApp.bleManager!=null){ if(MainApp.theApp.bleManager.isSupportBle()){ MainApp.theApp.bleManager.enableBluetooth(); @@ -234,23 +234,23 @@ /** * ������������ */ - if (Build.VERSION.SDK_INT >= 11) { - new checkUpdateTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } else { - new checkUpdateTask().execute(); - } +// if (Build.VERSION.SDK_INT >= 11) { +// new checkUpdateTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); +// } else { +// new checkUpdateTask().execute(); +// } if (islogin) return; String url = API.GET_INFO; Map<String, String> params = new HashMap<>(); - params.put("userID", MainApp.userId); + params.put("phone",MainApp.theApp.sharedPreferencesUtil.getLoginInfo().getPhone()); HttpUtils.doPost(url, params, CacheMode.DEFAULT, false, new HttpCallBack() { @Override public void onSuccess(String res, String msg) { User user = FastJsonTools.getJson(res, User.class); if (user != null) { MainApp.theApp.sharedPreferencesUtil.saveLoginInfo(user); -// MainApp.theApp.userId = user.get_id(); + MainApp.theApp.userId = user.get_id(); } } @@ -324,12 +324,16 @@ public void onConnectFail() { progressDialog.dismiss(); mToatUtils.showSingletonToast("������������"); + } @Override public void onDisConnected() { progressDialog.dismiss(); mToatUtils.showSingletonToast("������������"); + EventMessage msg = new EventMessage(); + msg.setType(AppConfig.GET_BLE_DISCONNECT); + EventBus.getDefault().post(msg); } @Override @@ -340,4 +344,54 @@ EventBus.getDefault().post(msg); } }; + +// private void registerBoradcastReceiver() { +// IntentFilter stateChangeFilter = new IntentFilter( +// BluetoothAdapter.ACTION_STATE_CHANGED); +// IntentFilter connectedFilter = new IntentFilter( +// BluetoothDevice.ACTION_ACL_CONNECTED); +// IntentFilter disConnectedFilter = new IntentFilter( +// BluetoothDevice.ACTION_ACL_DISCONNECTED); +// registerReceiver(stateChangeReceiver, stateChangeFilter); +// registerReceiver(stateChangeReceiver, connectedFilter); +// registerReceiver(stateChangeReceiver, disConnectedFilter); +// } +// +// private BroadcastReceiver stateChangeReceiver = new BroadcastReceiver() { +// @Override +// public void onReceive(Context context, Intent intent) { +// String action = intent.getAction(); +// if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) { +// mToatUtils.showSingletonToast("xxx������OK"); +// } +// if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) { +// mToatUtils.showSingletonToast("xxx������������"); +// } +// if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) { +// mToatUtils.showSingletonToast("xxx������������"); +// } +// } +// }; + +// private boolean isFinish = false; +// Timer timer; +// +// private void bleHeart() { +// timer = new Timer(); +// timer.schedule(new TimerTask() { +// @Override +// public void run() { +// if (!isFinish) { +// if(!MainApp.theApp.bleManager.isConnected()){ +// runOnUiThread(new Runnable() { +// @Override +// public void run() { +// mToatUtils.showSingletonToast("TMD������������"); +// } +// }); +// } +// } +// } +// }, 0, 10000); +// } } -- Gitblit v1.8.0