Commit 3376fc75f74c3fe11d5a4b974eed714f84f552d6

Authored by wugian
1 parent 4155c8d2

ft control smart screen

@@ -29,6 +29,8 @@ import android.graphics.Point; @@ -29,6 +29,8 @@ import android.graphics.Point;
29 import android.graphics.Rect; 29 import android.graphics.Rect;
30 import android.os.Bundle; 30 import android.os.Bundle;
31 import android.os.Handler; 31 import android.os.Handler;
  32 +import android.os.Looper;
  33 +import android.os.Message;
32 import android.support.v7.widget.GridLayoutManager; 34 import android.support.v7.widget.GridLayoutManager;
33 import android.support.v7.widget.RecyclerView; 35 import android.support.v7.widget.RecyclerView;
34 import android.text.TextUtils; 36 import android.text.TextUtils;
@@ -63,6 +65,7 @@ import com.gimi.common.cinema.utils.M1905Utils; @@ -63,6 +65,7 @@ import com.gimi.common.cinema.utils.M1905Utils;
63 import com.gimi.common.cinema.utils.OpenMMUtils; 65 import com.gimi.common.cinema.utils.OpenMMUtils;
64 import com.gimi.common.cinema.utils.ScreenUtils; 66 import com.gimi.common.cinema.utils.ScreenUtils;
65 import com.gimi.common.cinema.utils.SystemUtils; 67 import com.gimi.common.cinema.utils.SystemUtils;
  68 +import com.gimi.common.cinema.utils.Utils;
66 import com.google.gson.Gson; 69 import com.google.gson.Gson;
67 import com.qnbar.smc.model.Light; 70 import com.qnbar.smc.model.Light;
68 import com.qnbar.smc.model.Lights; 71 import com.qnbar.smc.model.Lights;
@@ -94,10 +97,20 @@ import com.xgimi.gimicinema.presenter.MainPresenter; @@ -94,10 +97,20 @@ import com.xgimi.gimicinema.presenter.MainPresenter;
94 import com.xgimi.gimicinema.view.ClazzItem; 97 import com.xgimi.gimicinema.view.ClazzItem;
95 import com.xgimi.gimicinema.view.MovieItem; 98 import com.xgimi.gimicinema.view.MovieItem;
96 import com.xgimi.gimicinema.view.OrderRecyclerView; 99 import com.xgimi.gimicinema.view.OrderRecyclerView;
  100 +import com.xgimi.smartscreen.SmartScreenBean;
  101 +import com.xgimi.smartscreen.service.ConfigService;
97 import org.greenrobot.eventbus.EventBus; 102 import org.greenrobot.eventbus.EventBus;
98 import org.greenrobot.eventbus.Subscribe; 103 import org.greenrobot.eventbus.Subscribe;
99 import org.greenrobot.eventbus.ThreadMode; 104 import org.greenrobot.eventbus.ThreadMode;
100 - 105 +import org.json.JSONException;
  106 +import org.json.JSONObject;
  107 +
  108 +import java.io.BufferedReader;
  109 +import java.io.IOException;
  110 +import java.io.InputStreamReader;
  111 +import java.io.PrintWriter;
  112 +import java.net.Socket;
  113 +import java.net.SocketTimeoutException;
101 import java.text.SimpleDateFormat; 114 import java.text.SimpleDateFormat;
102 import java.util.ArrayList; 115 import java.util.ArrayList;
103 import java.util.Date; 116 import java.util.Date;
@@ -161,10 +174,11 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -161,10 +174,11 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
161 mApplication.doInit(); 174 mApplication.doInit();
162 setContentView(R.layout.a_main); 175 setContentView(R.layout.a_main);
163 EventBus.getDefault().register(this); 176 EventBus.getDefault().register(this);
  177 + context = this;
164 178
165 initLight(); 179 initLight();
166 initLock(); 180 initLock();
167 - context = this; 181 + initScreen();
168 mData = new ArrayList<>(); 182 mData = new ArrayList<>();
169 clazzData = new ArrayList<>(); 183 clazzData = new ArrayList<>();
170 screenPoint = ScreenUtils.getScreenParam(context); 184 screenPoint = ScreenUtils.getScreenParam(context);
@@ -218,6 +232,105 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -218,6 +232,105 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
218 startService(intent); 232 startService(intent);
219 } 233 }
220 234
  235 + @Override
  236 + protected void onStart() {
  237 + super.onStart();
  238 + Log.d(TAG, "onStart");
  239 + int result = BuildUtils.assetSdkVersion("4.4");
  240 + Log.d(TAG, " Version : " + result);
  241 +
  242 + // 监听各种事件
  243 + mApplication.addEventListener(DeviceEvent.STATUS_CHANGED, this);
  244 + mApplication.addEventListener(NotificationEvent.ONLINE_STATUS, this);
  245 + mApplication.addEventListener(ServiceEvent.SERVICE_CONNECTED, this);
  246 + mApplication.addEventListener(MeshEvent.OFFLINE, this);
  247 + mApplication.addEventListener(MeshEvent.ERROR, this);
  248 + new Handler().postDelayed(new Runnable() {
  249 + @Override
  250 + public void run() {
  251 + MainActivity.this.autoConnect();
  252 + }
  253 + }, 3 * 1000);
  254 + }
  255 +
  256 + @Override
  257 + protected void onResume() {
  258 + super.onResume();
  259 + presenter.checkAuth();
  260 + if (mData != null) {
  261 + if (mData.size() == 0) {
  262 + presenter.loadRecommend(context);
  263 + }
  264 + }
  265 + if (HAS_SYSTEM_FEATURE_BLUETOOTH_LE) {
  266 + IntentFilter intentFilter = new IntentFilter();
  267 + intentFilter.addAction(BLEBroadcastReceiver.ACTION_BLE_ERROR);
  268 + intentFilter.addAction(BLEBroadcastReceiver.ACTION_SHAKING_BLE_ERROR);
  269 + intentFilter.addAction(BLEBroadcastReceiver.ACTION_WRITTEN_SUCCESS);
  270 + registerReceiver(bleBroadcastReceiver, intentFilter);
  271 + }
  272 + if (!LeBluetooth.getInstance().isSupport(getApplicationContext())) {
  273 + Toast.makeText(this, "ble not support", Toast.LENGTH_SHORT).show();
  274 + finish();
  275 + return;
  276 + }
  277 +
  278 + if (!LeBluetooth.getInstance().isEnabled()) {
  279 +// AlertDialog.Builder builder = new AlertDialog.Builder(this);
  280 +// builder.setMessage("开启蓝牙,体验智能灯!");
  281 +// builder.setNeutralButton("cancel", new DialogInterface.OnClickListener() {
  282 +// @Override
  283 +// public void onClick(DialogInterface dialog, int which) {
  284 +// finish();
  285 +// }
  286 +// });
  287 +// builder.setNegativeButton("enable", new DialogInterface.OnClickListener() {
  288 +// @Override
  289 +// public void onClick(DialogInterface dialog, int which) {
  290 + LeBluetooth.getInstance().enable(getApplicationContext());
  291 + Log.d(TAG, "开启蓝牙,体验智能灯!");
  292 +// }
  293 +// });
  294 +// builder.show();
  295 + }
  296 +
  297 + DeviceInfo deviceInfo = mApplication.getConnectDevice();
  298 +
  299 + if (deviceInfo != null) {
  300 + connectMeshAddress = mApplication.getConnectDevice().meshAddress & 0xFF;
  301 + } else {
  302 + autoConnect();
  303 + }
  304 + if (findCount++ < 5) {
  305 + if (!findHub || !findSwitch) {
  306 + initSwitch();
  307 + Log.d(TAG, "re init switch");
  308 + }
  309 + } else {
  310 + Log.d(TAG, "find switch more than 5 times ,there may not exist right switch");
  311 + }
  312 +
  313 +
  314 + Log.d(TAG, "onResume");
  315 + }
  316 +
  317 + @Override
  318 + protected void onPause() {
  319 + super.onPause();
  320 + isSearching = false;
  321 + if (HAS_SYSTEM_FEATURE_BLUETOOTH_LE) {
  322 + unregisterReceiver(bleBroadcastReceiver);
  323 + }
  324 + }
  325 +
  326 + @Override
  327 + protected void onDestroy() {
  328 + super.onDestroy();
  329 + presenter.umountSamba();
  330 + unregisterReceiver(mReceiver);
  331 + EventBus.getDefault().unregister(this);
  332 + }
  333 +
221 334
222 @Override 335 @Override
223 public void loadCtrlImg(Bitmap bitmap) { 336 public void loadCtrlImg(Bitmap bitmap) {
@@ -351,67 +464,6 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -351,67 +464,6 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
351 } 464 }
352 465
353 466
354 - @Override  
355 - protected void onResume() {  
356 - super.onResume();  
357 - presenter.checkAuth();  
358 - if (mData != null) {  
359 - if (mData.size() == 0) {  
360 - presenter.loadRecommend(context);  
361 - }  
362 - }  
363 - if (HAS_SYSTEM_FEATURE_BLUETOOTH_LE) {  
364 - IntentFilter intentFilter = new IntentFilter();  
365 - intentFilter.addAction(BLEBroadcastReceiver.ACTION_BLE_ERROR);  
366 - intentFilter.addAction(BLEBroadcastReceiver.ACTION_SHAKING_BLE_ERROR);  
367 - intentFilter.addAction(BLEBroadcastReceiver.ACTION_WRITTEN_SUCCESS);  
368 - registerReceiver(bleBroadcastReceiver, intentFilter);  
369 - }  
370 - if (!LeBluetooth.getInstance().isSupport(getApplicationContext())) {  
371 - Toast.makeText(this, "ble not support", Toast.LENGTH_SHORT).show();  
372 - finish();  
373 - return;  
374 - }  
375 -  
376 - if (!LeBluetooth.getInstance().isEnabled()) {  
377 -// AlertDialog.Builder builder = new AlertDialog.Builder(this);  
378 -// builder.setMessage("开启蓝牙,体验智能灯!");  
379 -// builder.setNeutralButton("cancel", new DialogInterface.OnClickListener() {  
380 -// @Override  
381 -// public void onClick(DialogInterface dialog, int which) {  
382 -// finish();  
383 -// }  
384 -// });  
385 -// builder.setNegativeButton("enable", new DialogInterface.OnClickListener() {  
386 -// @Override  
387 -// public void onClick(DialogInterface dialog, int which) {  
388 - LeBluetooth.getInstance().enable(getApplicationContext());  
389 - Log.d(TAG, "开启蓝牙,体验智能灯!");  
390 -// }  
391 -// });  
392 -// builder.show();  
393 - }  
394 -  
395 - DeviceInfo deviceInfo = mApplication.getConnectDevice();  
396 -  
397 - if (deviceInfo != null) {  
398 - connectMeshAddress = mApplication.getConnectDevice().meshAddress & 0xFF;  
399 - } else {  
400 - autoConnect();  
401 - }  
402 - if (findCount++ < 5) {  
403 - if (!findHub || !findSwitch) {  
404 - initSwitch();  
405 - Log.d(TAG, "re init switch");  
406 - }  
407 - } else {  
408 - Log.d(TAG, "find switch more than 5 times ,there may not exist right switch");  
409 - }  
410 -  
411 -  
412 - Log.d(TAG, "onResume");  
413 - }  
414 -  
415 int findCount = 0; 467 int findCount = 0;
416 468
417 @Override 469 @Override
@@ -431,14 +483,6 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -431,14 +483,6 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
431 return super.onKeyDown(keyCode, event); 483 return super.onKeyDown(keyCode, event);
432 } 484 }
433 485
434 - @Override  
435 - protected void onPause() {  
436 - super.onPause();  
437 - if (HAS_SYSTEM_FEATURE_BLUETOOTH_LE) {  
438 - unregisterReceiver(bleBroadcastReceiver);  
439 - }  
440 - }  
441 -  
442 486
443 private class MovieListAdapter 487 private class MovieListAdapter
444 extends RecyclerView.Adapter<MovieListAdapter.MovieListViewHolder> 488 extends RecyclerView.Adapter<MovieListAdapter.MovieListViewHolder>
@@ -621,17 +665,8 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -621,17 +665,8 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
621 presenter.jumpToSearch(); 665 presenter.jumpToSearch();
622 } 666 }
623 667
624 - @Override  
625 - protected void onDestroy() {  
626 - super.onDestroy();  
627 - presenter.umountSamba();  
628 - unregisterReceiver(mReceiver);  
629 - EventBus.getDefault().unregister(this);  
630 - }  
631 -  
632 668
633 //lock 669 //lock
634 - private String openCMD = "Open the door";  
635 // private String onClickDeviceMac; 670 // private String onClickDeviceMac;
636 671
637 private boolean HAS_SYSTEM_FEATURE_BLUETOOTH_LE = true; 672 private boolean HAS_SYSTEM_FEATURE_BLUETOOTH_LE = true;
@@ -671,27 +706,6 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -671,27 +706,6 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
671 GREENBLE.send(this, "DC:F6:70:C1:AA:D6", openCMD.getBytes());*/ 706 GREENBLE.send(this, "DC:F6:70:C1:AA:D6", openCMD.getBytes());*/
672 } 707 }
673 708
674 - @Override  
675 - protected void onStart() {  
676 - super.onStart();  
677 - Log.d(TAG, "onStart");  
678 - int result = BuildUtils.assetSdkVersion("4.4");  
679 - Log.d(TAG, " Version : " + result);  
680 -  
681 - // 监听各种事件  
682 - mApplication.addEventListener(DeviceEvent.STATUS_CHANGED, this);  
683 - mApplication.addEventListener(NotificationEvent.ONLINE_STATUS, this);  
684 - mApplication.addEventListener(ServiceEvent.SERVICE_CONNECTED, this);  
685 - mApplication.addEventListener(MeshEvent.OFFLINE, this);  
686 - mApplication.addEventListener(MeshEvent.ERROR, this);  
687 - new Handler().postDelayed(new Runnable() {  
688 - @Override  
689 - public void run() {  
690 - MainActivity.this.autoConnect();  
691 - }  
692 - }, 3 * 1000);  
693 - }  
694 -  
695 //lights 709 //lights
696 710
697 private FangTangApplication mApplication; 711 private FangTangApplication mApplication;
@@ -878,6 +892,9 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -878,6 +892,9 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
878 switch (messageEvent.getEventId()) { 892 switch (messageEvent.getEventId()) {
879 case OPEN_DOOR_CMD: 893 case OPEN_DOOR_CMD:
880 openDoor(); 894 openDoor();
  895 + if (rightSn) {
  896 + down();
  897 + }
881 Log.d("event bus", messageEvent.getMessage()); 898 Log.d("event bus", messageEvent.getMessage());
882 Log.d("event bus", "open door"); 899 Log.d("event bus", "open door");
883 // MessageEvent msgEvent = new MessageEvent(); 900 // MessageEvent msgEvent = new MessageEvent();
@@ -944,6 +961,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -944,6 +961,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
944 } 961 }
945 962
946 }); 963 });
  964 + String openCMD = "Open the door";
947 GREENBLE.send(this, "DC:F6:70:C1:AA:D6", openCMD.getBytes()); 965 GREENBLE.send(this, "DC:F6:70:C1:AA:D6", openCMD.getBytes());
948 List<LocalMovieMessage> localMovieMessages = new NewDBManager(this).queryRandomMovies(); 966 List<LocalMovieMessage> localMovieMessages = new NewDBManager(this).queryRandomMovies();
949 if (localMovieMessages != null && localMovieMessages.size() > 0) { 967 if (localMovieMessages != null && localMovieMessages.size() > 0) {
@@ -1003,4 +1021,171 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -1003,4 +1021,171 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
1003 } 1021 }
1004 } 1022 }
1005 //---------------------------about switch----------------------------------- 1023 //---------------------------about switch-----------------------------------
  1024 +
  1025 + //---------------------------about screen-----------------------------------
  1026 + private boolean rightSn = false;
  1027 + private boolean isSearching = false;
  1028 + private String mDeviceIp = "";
  1029 + private MessageThread messageThread;
  1030 + private static final int PORT = 8009;
  1031 + List<String> listData = new ArrayList<>();
  1032 +
  1033 + void initScreen() {
  1034 + startService(new Intent(this, ConfigService.class));
  1035 + mDeviceIp = Utils.getString(context, "screen-ip");
  1036 + if (TextUtils.isEmpty(mDeviceIp)) {
  1037 + show("没有配置智能幕布");
  1038 + return;
  1039 + }
  1040 + messageThread = new MessageThread();
  1041 +
  1042 + new Thread(messageThread).start();
  1043 +
  1044 + new Handler().postDelayed(new Runnable() {
  1045 + public void run() {
  1046 + getDeviceInfo(null);
  1047 + }
  1048 + }, 1000);
  1049 + }
  1050 +
  1051 + private void getDeviceInfo(String ip) {
  1052 + if (!TextUtils.isEmpty(ip)) {
  1053 + mDeviceIp = ip;
  1054 + }
  1055 + JSONObject dataGetInfo = new JSONObject();
  1056 + try {
  1057 + dataGetInfo.put("cmd", 1);
  1058 + } catch (JSONException e) {
  1059 + e.printStackTrace();
  1060 + }
  1061 +
  1062 + sendMsg(0x345, dataGetInfo);
  1063 + }
  1064 +
  1065 + private void sendMsg(int msgId, Object msg) {
  1066 + Message msgGetInfo = new Message();
  1067 + msgGetInfo.what = msgId;
  1068 + msgGetInfo.obj = msg;
  1069 + messageThread.sendHandler.sendMessage(msgGetInfo);
  1070 + }
  1071 +
  1072 + Handler handler = new Handler() {
  1073 + @Override
  1074 + public void handleMessage(Message msg) {
  1075 + super.handleMessage(msg);
  1076 +
  1077 + if (msg.what == 0x123) {
  1078 + String data = (msg.obj).toString();
  1079 + try {
  1080 + JSONObject jsonObject = new JSONObject(data);
  1081 + int cmd = jsonObject.getInt("cmd");
  1082 + if (cmd == 1) {
  1083 + int sn = jsonObject.getInt("sn");
  1084 + if (sn == Utils.getInt(context, "screen-sn", -1)) {
  1085 + rightSn = true;
  1086 + Log.d(TAG, "rightSn:" + rightSn);
  1087 + }
  1088 + }
  1089 + } catch (JSONException e) {
  1090 + e.printStackTrace();
  1091 + }
  1092 + }
  1093 + }
  1094 + };
  1095 +
  1096 +
  1097 + public class MessageThread implements Runnable {
  1098 + //接收UI线程消息的Handler对象
  1099 + public Handler sendHandler;
  1100 +
  1101 + private Socket socket;
  1102 + BufferedReader br = null;
  1103 + PrintWriter pw = null;
  1104 +
  1105 + @Override
  1106 + public void run() {
  1107 +
  1108 + try {
  1109 + socket = new Socket(mDeviceIp, PORT);
  1110 + br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
  1111 + pw = new PrintWriter(socket.getOutputStream());
  1112 +
  1113 + //启动一个线程来读取数据
  1114 + new Thread(new Runnable() {
  1115 + @Override
  1116 + public void run() {
  1117 +
  1118 + String data = null;
  1119 +
  1120 + try {
  1121 + while ((data = br.readLine()) != null) {
  1122 + Log.i(TAG, "接收到的数据:" + data);
  1123 +
  1124 + Message msg = new Message();
  1125 + msg.what = 0x123;
  1126 + msg.obj = data;
  1127 + handler.sendMessage(msg);
  1128 + }
  1129 +
  1130 + } catch (IOException e) {
  1131 + Log.i(TAG, "接收数据异常:" + e.getMessage());
  1132 + e.printStackTrace();
  1133 + }
  1134 +
  1135 + }
  1136 + }).start();
  1137 +
  1138 + Looper.prepare();
  1139 + sendHandler = new Handler() {
  1140 + @Override
  1141 + public void handleMessage(Message msg) {
  1142 + super.handleMessage(msg);
  1143 +
  1144 + if (msg.what == 0x345) {
  1145 + Log.i(TAG, "写数据:" + (msg.obj).toString());
  1146 + pw.write((msg.obj).toString());
  1147 +// pw.write("{\"cmd\":2,\"action\":0}");
  1148 + pw.flush();
  1149 + }
  1150 + }
  1151 + };
  1152 + //启动Looper
  1153 + Looper.loop();
  1154 +
  1155 + } catch (SocketTimeoutException e) {
  1156 + Log.i(TAG, "网络连接超时!");
  1157 + } catch (IOException e) {
  1158 + e.printStackTrace();
  1159 + } finally {
  1160 + try {
  1161 + if (pw != null) {
  1162 + pw.close();
  1163 + }
  1164 + if (br != null) {
  1165 + br.close();
  1166 + }
  1167 + if (socket != null) {
  1168 + socket.close();
  1169 + }
  1170 + } catch (IOException e) {
  1171 + e.printStackTrace();
  1172 + }
  1173 + }
  1174 + }
  1175 + }
  1176 +
  1177 + public void down() {
  1178 + MessageEvent msgEvent = new MessageEvent();
  1179 + msgEvent.setEventId(SmartScreenBean.DOWNACTION);
  1180 + msgEvent.setMessage(mDeviceIp);
  1181 + EventBus.getDefault().post(msgEvent);
  1182 + }
  1183 +
  1184 + public void up() {
  1185 + MessageEvent msgEvent = new MessageEvent();
  1186 + msgEvent.setEventId(SmartScreenBean.UPACTION);
  1187 + msgEvent.setMessage(mDeviceIp);
  1188 + EventBus.getDefault().post(msgEvent);
  1189 + }
  1190 + //---------------------------about screen-----------------------------------
1006 } 1191 }
@@ -14,7 +14,6 @@ import android.text.TextUtils; @@ -14,7 +14,6 @@ import android.text.TextUtils;
14 import android.util.Log; 14 import android.util.Log;
15 import android.widget.Toast; 15 import android.widget.Toast;
16 import com.gimi.common.cinema.model.MessageEvent; 16 import com.gimi.common.cinema.model.MessageEvent;
17 -import com.google.gson.Gson;  
18 import com.xgimi.smartscreen.SmartScreenBean; 17 import com.xgimi.smartscreen.SmartScreenBean;
19 import com.xgimi.smartscreen.confignetwork.ChTask; 18 import com.xgimi.smartscreen.confignetwork.ChTask;
20 import com.xgimi.smartscreen.confignetwork.IChListener; 19 import com.xgimi.smartscreen.confignetwork.IChListener;
@@ -101,7 +100,7 @@ public class ConfigService extends Service { @@ -101,7 +100,7 @@ public class ConfigService extends Service {
101 getNetStat(); 100 getNetStat();
102 } 101 }
103 102
104 - String action = intent.getAction(); 103 + /* String action = intent.getAction();
105 if ("com.xgimi.smartscreen.ACTION.CONTROL".equals(action)) { 104 if ("com.xgimi.smartscreen.ACTION.CONTROL".equals(action)) {
106 state = intent.getIntExtra("CONTROL", -1); 105 state = intent.getIntExtra("CONTROL", -1);
107 String ip = intent.getStringExtra("CONTROLIP"); 106 String ip = intent.getStringExtra("CONTROLIP");
@@ -115,7 +114,7 @@ public class ConfigService extends Service { @@ -115,7 +114,7 @@ public class ConfigService extends Service {
115 XgimiSettingsSP.putString(ConfigService.this, "BINDINFO", bindInfo); 114 XgimiSettingsSP.putString(ConfigService.this, "BINDINFO", bindInfo);
116 Intent notifyIntent = new Intent("com.xgimi.smartscreen.ACTION.DEVICEBIND"); 115 Intent notifyIntent = new Intent("com.xgimi.smartscreen.ACTION.DEVICEBIND");
117 sendBroadcast(notifyIntent); 116 sendBroadcast(notifyIntent);
118 - }/*else if("com.xgimi.smartscreen.ACTION.POWEROFF".equals(action)){ 117 + }*//*else if("com.xgimi.smartscreen.ACTION.POWEROFF".equals(action)){
119 state = SmartScreenBean.UPACTION; 118 state = SmartScreenBean.UPACTION;
120 hasTask = true; 119 hasTask = true;
121 String bindInfo = XgimiSettingsSP.getString(ConfigService.this,"BINDINFO"); 120 String bindInfo = XgimiSettingsSP.getString(ConfigService.this,"BINDINFO");
@@ -230,9 +229,13 @@ public class ConfigService extends Service { @@ -230,9 +229,13 @@ public class ConfigService extends Service {
230 if (cmd == 2) { 229 if (cmd == 2) {
231 int result = jsonObject.getInt("result"); 230 int result = jsonObject.getInt("result");
232 if (result == 1) { //成功 231 if (result == 1) { //成功
  232 + Toast.makeText(ConfigService.this, "操作成功", Toast.LENGTH_SHORT).show();
233 Log.e(TAG, "操作成功"); 233 Log.e(TAG, "操作成功");
234 - } else if (result == 0) { //失败  
235 - Log.e(TAG, "操作失败"); 234 + } else {
  235 + if (result == 0) { //失败
  236 + Toast.makeText(ConfigService.this, "操作失败", Toast.LENGTH_SHORT).show();
  237 + Log.e(TAG, "操作失败");
  238 + }
236 } 239 }
237 } 240 }
238 } catch (JSONException e) { 241 } catch (JSONException e) {
@@ -461,19 +464,19 @@ public class ConfigService extends Service { @@ -461,19 +464,19 @@ public class ConfigService extends Service {
461 smartScreenBean.ip = s; 464 smartScreenBean.ip = s;
462 smartScreenBean.name = "极米智能幕布"; 465 smartScreenBean.name = "极米智能幕布";
463 smartScreenBean.state = 0; 466 smartScreenBean.state = 0;
464 - String bindInfo = new Gson().toJson(smartScreenBean, SmartScreenBean.class);  
465 - XgimiSettingsSP.putString(ConfigService.this, "BINDINFO", bindInfo);  
466 - Intent notifyIntent = new Intent("com.xgimi.smartscreen.ACTION.DEVICEBIND");  
467 - sendBroadcast(notifyIntent); 467 +// String bindInfo = new Gson().toJson(smartScreenBean, SmartScreenBean.class);
  468 +// XgimiSettingsSP.putString(ConfigService.this, "BINDINFO", bindInfo);
  469 +// Intent notifyIntent = new Intent("com.xgimi.smartscreen.ACTION.DEVICEBIND");
  470 +// sendBroadcast(notifyIntent);
468 if (hasTask) { 471 if (hasTask) {
469 Control(s, state); 472 Control(s, state);
470 hasTask = false; 473 hasTask = false;
471 } 474 }
472 } else { 475 } else {
473 Log.e(TAG, "没有发现设备!"); 476 Log.e(TAG, "没有发现设备!");
474 - XgimiSettingsSP.putString(ConfigService.this, "BINDINFO", "");  
475 - Intent notifyIntent = new Intent("com.xgimi.smartscreen.ACTION.NODEVICE");  
476 - sendBroadcast(notifyIntent); 477 +// XgimiSettingsSP.putString(ConfigService.this, "BINDINFO", "");
  478 +// Intent notifyIntent = new Intent("com.xgimi.smartscreen.ACTION.NODEVICE");
  479 +// sendBroadcast(notifyIntent);
477 } 480 }
478 } 481 }
479 } 482 }
Please register or login to post a comment