Commit 785836774dca01116e2553b66f5c560bdef2fd83

Authored by wugian
1 parent e9f800d8

开关门时间调整,显示清理二维码,更新库

@@ -123,7 +123,7 @@ android { @@ -123,7 +123,7 @@ android {
123 123
124 dependencies { 124 dependencies {
125 compile files('libs/decoder.jar') 125 compile files('libs/decoder.jar')
126 - compile files('libs/cinemaLib-1220.jar') 126 + compile files('libs/CinemaLibs-170426.jar')
127 compile files('libs/glide-3.7.0.jar') 127 compile files('libs/glide-3.7.0.jar')
128 compile files('libs/greenbluetoothlelib.jar') 128 compile files('libs/greenbluetoothlelib.jar')
129 129
No preview for this file type
@@ -145,6 +145,7 @@ @@ -145,6 +145,7 @@
145 </activity> 145 </activity>
146 146
147 <service android:name="com.xgimi.smartscreen.service.ConfigService"/> 147 <service android:name="com.xgimi.smartscreen.service.ConfigService"/>
  148 + <service android:name=".poll.PollingServiceDemo"/>
148 149
149 <activity android:name=".activity.QrCodeShowActivity"> 150 <activity android:name=".activity.QrCodeShowActivity">
150 </activity> 151 </activity>
@@ -22,6 +22,7 @@ public class RoomStatusInfo extends BaseModel { @@ -22,6 +22,7 @@ public class RoomStatusInfo extends BaseModel {
22 private int end_time; 22 private int end_time;
23 private int status; 23 private int status;
24 private String film_hash; 24 private String film_hash;
  25 + private int now_time;
25 26
26 public String getOrder_sn() { 27 public String getOrder_sn() {
27 return order_sn; 28 return order_sn;
@@ -63,6 +64,14 @@ public class RoomStatusInfo extends BaseModel { @@ -63,6 +64,14 @@ public class RoomStatusInfo extends BaseModel {
63 this.film_hash = film_hash; 64 this.film_hash = film_hash;
64 } 65 }
65 66
  67 + public int getNow_time() {
  68 + return now_time;
  69 + }
  70 +
  71 + public void setNow_time(int now_time) {
  72 + this.now_time = now_time;
  73 + }
  74 +
66 @Override 75 @Override
67 public String toString() { 76 public String toString() {
68 return "DataEntity{" + 77 return "DataEntity{" +
@@ -71,6 +80,7 @@ public class RoomStatusInfo extends BaseModel { @@ -71,6 +80,7 @@ public class RoomStatusInfo extends BaseModel {
71 ", end_time=" + end_time + 80 ", end_time=" + end_time +
72 ", status=" + status + 81 ", status=" + status +
73 ", film_hash='" + film_hash + '\'' + 82 ", film_hash='" + film_hash + '\'' +
  83 + ", now_time=" + now_time +
74 '}'; 84 '}';
75 } 85 }
76 } 86 }
@@ -64,6 +64,7 @@ import com.gimi.common.cinema.model.RoomInfo; @@ -64,6 +64,7 @@ import com.gimi.common.cinema.model.RoomInfo;
64 import com.gimi.common.cinema.model.RoomQrCodeInfo; 64 import com.gimi.common.cinema.model.RoomQrCodeInfo;
65 import com.gimi.common.cinema.model.RoomStatusInfo; 65 import com.gimi.common.cinema.model.RoomStatusInfo;
66 import com.gimi.common.cinema.utils.AuthUtils; 66 import com.gimi.common.cinema.utils.AuthUtils;
  67 +import com.gimi.common.cinema.utils.CToast;
67 import com.gimi.common.cinema.utils.LeeImageLoader; 68 import com.gimi.common.cinema.utils.LeeImageLoader;
68 import com.gimi.common.cinema.utils.M1905Utils; 69 import com.gimi.common.cinema.utils.M1905Utils;
69 import com.gimi.common.cinema.utils.NetStatusUtils; 70 import com.gimi.common.cinema.utils.NetStatusUtils;
@@ -120,6 +121,7 @@ import java.net.Socket; @@ -120,6 +121,7 @@ import java.net.Socket;
120 import java.net.SocketTimeoutException; 121 import java.net.SocketTimeoutException;
121 import java.text.SimpleDateFormat; 122 import java.text.SimpleDateFormat;
122 import java.util.ArrayList; 123 import java.util.ArrayList;
  124 +import java.util.Calendar;
123 import java.util.Date; 125 import java.util.Date;
124 import java.util.List; 126 import java.util.List;
125 import java.util.Locale; 127 import java.util.Locale;
@@ -181,7 +183,6 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -181,7 +183,6 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
181 setContentView(R.layout.a_main); 183 setContentView(R.layout.a_main);
182 EventBus.getDefault().register(this); 184 EventBus.getDefault().register(this);
183 context = this; 185 context = this;
184 -  
185 initLight(); 186 initLight();
186 initLock(); 187 initLock();
187 initScreen(); 188 initScreen();
@@ -237,13 +238,31 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -237,13 +238,31 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
237 presenter.load(this); 238 presenter.load(this);
238 Intent intent = new Intent(this, SocketService.class); 239 Intent intent = new Intent(this, SocketService.class);
239 startService(intent); 240 startService(intent);
240 - new Handler().postDelayed(new Runnable() {  
241 - @Override  
242 - public void run() {  
243 - Log.d("room-info", "test open door report");  
244 - openDoor();  
245 - }  
246 - }, 5 * 1000); 241 + final long l = (System.currentTimeMillis() / 60000) % (24 * 60) + 480;
  242 + SimpleDateFormat sdf = new SimpleDateFormat(" yyyy-MM-dd ", Locale.SIMPLIFIED_CHINESE);
  243 + getTimeByCalendar();
  244 + presenter.getOrderInfo();
  245 +// new Handler().postDelayed(new Runnable() {
  246 +// @Override
  247 +// public void run() {
  248 +// Log.d("room-info", "test open door report");
  249 +// openDoor();
  250 +// }
  251 +// }, 5 * 1000);
  252 + }
  253 +
  254 + public void getTimeByCalendar() {
  255 + Calendar cal = Calendar.getInstance();
  256 + int year = cal.get(Calendar.YEAR);//获取年份
  257 + int month = cal.get(Calendar.MONTH);//获取月份
  258 + int day = cal.get(Calendar.DATE);//获取日
  259 + int hour = cal.get(Calendar.HOUR_OF_DAY);//小时
  260 + int minute = cal.get(Calendar.MINUTE);//分
  261 + int second = cal.get(Calendar.SECOND);//秒
  262 + int WeekOfYear = cal.get(Calendar.DAY_OF_WEEK);//一周的第几天
  263 + Log.d("room-info", "现在的时间是:公元" + year + "年" + month + "月" + day + "日 " + hour + "时" + minute + "分" + second + "秒 星期" + WeekOfYear);
  264 + Log.d("room-info", "current minute:" + (hour * 60 + minute) + "");
  265 +
247 } 266 }
248 267
249 @Override 268 @Override
@@ -284,7 +303,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -284,7 +303,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
284 registerReceiver(bleBroadcastReceiver, intentFilter); 303 registerReceiver(bleBroadcastReceiver, intentFilter);
285 } 304 }
286 if (!LeBluetooth.getInstance().isSupport(getApplicationContext())) { 305 if (!LeBluetooth.getInstance().isSupport(getApplicationContext())) {
287 - Toast.makeText(this, "ble not support", Toast.LENGTH_SHORT).show(); 306 + Toast.makeText(this, "蓝牙不支持", Toast.LENGTH_SHORT).show();
288 // finish(); 307 // finish();
289 // return; 308 // return;
290 } 309 }
@@ -316,15 +335,15 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -316,15 +335,15 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
316 protected void onPause() { 335 protected void onPause() {
317 super.onPause(); 336 super.onPause();
318 isSearching = false; 337 isSearching = false;
319 - if (HAS_SYSTEM_FEATURE_BLUETOOTH_LE) {  
320 - unregisterReceiver(bleBroadcastReceiver);  
321 - }  
322 } 338 }
323 339
324 @Override 340 @Override
325 protected void onDestroy() { 341 protected void onDestroy() {
326 super.onDestroy(); 342 super.onDestroy();
327 presenter.umountSamba(); 343 presenter.umountSamba();
  344 + if (HAS_SYSTEM_FEATURE_BLUETOOTH_LE) {
  345 + unregisterReceiver(bleBroadcastReceiver);
  346 + }
328 unregisterReceiver(mReceiver); 347 unregisterReceiver(mReceiver);
329 EventBus.getDefault().unregister(this); 348 EventBus.getDefault().unregister(this);
330 } 349 }
@@ -466,7 +485,12 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -466,7 +485,12 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
466 public void updateOrderInfo(RoomStatusInfo info) { 485 public void updateOrderInfo(RoomStatusInfo info) {
467 roomStatusInfo = info; 486 roomStatusInfo = info;
468 RoomStatusInfo.DataEntity data = info.getData(); 487 RoomStatusInfo.DataEntity data = info.getData();
469 - int durationMinutes = data.getEnd_time() - data.getBegin_time(); 488 + int offset = data.getNow_time() - data.getBegin_time();
  489 + if (offset > 3) {
  490 + CToast.makeText(context, "您已迟到" + offset + "分钟,请注意把握时间", 100 * 1000).show();
  491 + }
  492 +// int durationMinutes = data.getEnd_time() - data.getBegin_time() - offset;
  493 + int durationMinutes = data.getEnd_time() - data.getNow_time();
470 Log.d("CountService", "durationMinutes:" + durationMinutes); 494 Log.d("CountService", "durationMinutes:" + durationMinutes);
471 if (durationMinutes <= 1) { 495 if (durationMinutes <= 1) {
472 return; 496 return;
@@ -477,6 +501,9 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -477,6 +501,9 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
477 LocalMovieMessage localMovieMessages = null; 501 LocalMovieMessage localMovieMessages = null;
478 if (!TextUtils.isEmpty(data.getFilm_hash())) { 502 if (!TextUtils.isEmpty(data.getFilm_hash())) {
479 localMovieMessages = new NewDBManager(this).queryPlayMovie(data.getFilm_hash()); 503 localMovieMessages = new NewDBManager(this).queryPlayMovie(data.getFilm_hash());
  504 + if (localMovieMessages == null) {
  505 + show("电影信息出错,找不到相关电影");
  506 + }
480 } 507 }
481 if (localMovieMessages == null) { 508 if (localMovieMessages == null) {
482 show("没有获取到相应订单信息,即将为您播放银河护卫队"); 509 show("没有获取到相应订单信息,即将为您播放银河护卫队");
@@ -753,6 +780,8 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -753,6 +780,8 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
753 780
754 public void openSearch(View view) { 781 public void openSearch(View view) {
755 presenter.jumpToSearch(); 782 presenter.jumpToSearch();
  783 +// openDoor();
  784 +// PollingUtils.startPollingService(this.getApplicationContext(), 60, PollingServiceDemo.class, PollingServiceDemo.ACTION);
756 } 785 }
757 786
758 787
@@ -953,10 +982,13 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -953,10 +982,13 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
953 registerReceiver(mReceiver, filter); 982 registerReceiver(mReceiver, filter);
954 } 983 }
955 984
  985 + boolean needReport = false;
  986 +
956 @Subscribe(threadMode = ThreadMode.MAIN) 987 @Subscribe(threadMode = ThreadMode.MAIN)
957 public void onMoonEvent(MessageEvent messageEvent) { 988 public void onMoonEvent(MessageEvent messageEvent) {
958 switch (messageEvent.getEventId()) { 989 switch (messageEvent.getEventId()) {
959 case SocketService.JUST_OPEN_DOOR: 990 case SocketService.JUST_OPEN_DOOR:
  991 + needReport = false;
960 openDoor(); 992 openDoor();
961 if (rightSn) { 993 if (rightSn) {
962 down(); 994 down();
@@ -964,6 +996,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -964,6 +996,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
964 Log.d("event bus", "open door" + messageEvent.getMessage()); 996 Log.d("event bus", "open door" + messageEvent.getMessage());
965 break; 997 break;
966 case SocketService.USER_OPEN_DOOR_AND_GET_MOVIE: 998 case SocketService.USER_OPEN_DOOR_AND_GET_MOVIE:
  999 + needReport = true;
967 openDoor(); 1000 openDoor();
968 if (rightSn) { 1001 if (rightSn) {
969 down(); 1002 down();
@@ -972,6 +1005,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -972,6 +1005,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
972 Log.d("event bus", "open door" + messageEvent.getMessage()); 1005 Log.d("event bus", "open door" + messageEvent.getMessage());
973 break; 1006 break;
974 case SocketService.USER_OPEN_DOOR: 1007 case SocketService.USER_OPEN_DOOR:
  1008 + needReport = true;
975 openDoor(); 1009 openDoor();
976 if (rightSn) { 1010 if (rightSn) {
977 down(); 1011 down();
@@ -1030,9 +1064,9 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -1030,9 +1064,9 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
1030 } 1064 }
1031 break; 1065 break;
1032 case CountService.COUNT_DOWN_ZERO: 1066 case CountService.COUNT_DOWN_ZERO:
1033 - if (info == null || info.getData() == null) {  
1034 - break;  
1035 - } 1067 +// if (info == null || info.getData() == null) {
  1068 +// break;
  1069 +// }
1036 presenter.getCleanQrCode(roomStatusInfo.getData().getOrder_sn()); 1070 presenter.getCleanQrCode(roomStatusInfo.getData().getOrder_sn());
1037 // startActivity(new Intent(this, QrCodeShowActivity.class).putExtra("qr", "updateOrderInfo")); 1071 // startActivity(new Intent(this, QrCodeShowActivity.class).putExtra("qr", "updateOrderInfo"));
1038 break; 1072 break;
@@ -1040,6 +1074,8 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -1040,6 +1074,8 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
1040 } 1074 }
1041 1075
1042 private void openDoor() { 1076 private void openDoor() {
  1077 + //open LED
  1078 + new SystemUtils().openFtLed(context);
1043 Log.d("room-info", "openDoor called"); 1079 Log.d("room-info", "openDoor called");
1044 bleBroadcastReceiver.setResponseObj(new GREENCITYBLEProtocolFactory.GREENCITYBleDataWritten() { 1080 bleBroadcastReceiver.setResponseObj(new GREENCITYBLEProtocolFactory.GREENCITYBleDataWritten() {
1045 1081
@@ -1054,8 +1090,11 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -1054,8 +1090,11 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
1054 intent.setAction(GREENBluetoothLeService.ACTION_OPEN_SUCCESS); 1090 intent.setAction(GREENBluetoothLeService.ACTION_OPEN_SUCCESS);
1055 intent.putExtra("openrecord", bleOpenRecord); 1091 intent.putExtra("openrecord", bleOpenRecord);
1056 sendBroadcast(intent); 1092 sendBroadcast(intent);
  1093 + if (needReport) {
  1094 + handler.postDelayed(reportRunnable, 10 * 1000);
  1095 + Log.d("room-info", "user open door ,report the open success status");
  1096 + }
1057 Log.d("room-info", "open success"); 1097 Log.d("room-info", "open success");
1058 - handler.postDelayed(reportRunnable, 30 * 1000);  
1059 } 1098 }
1060 1099
1061 @Override 1100 @Override
@@ -24,6 +24,7 @@ import com.gimi.common.cinema.model.MessageEvent; @@ -24,6 +24,7 @@ import com.gimi.common.cinema.model.MessageEvent;
24 import com.gimi.common.cinema.model.SambaMsg; 24 import com.gimi.common.cinema.model.SambaMsg;
25 import com.gimi.common.cinema.utils.T; 25 import com.gimi.common.cinema.utils.T;
26 import com.gimi.common.cinema.utils.WifiApManger; 26 import com.gimi.common.cinema.utils.WifiApManger;
  27 +import com.qnbar.smc.service.SocketService;
27 import com.xgimi.gimicinema.BuildConfig; 28 import com.xgimi.gimicinema.BuildConfig;
28 import com.xgimi.gimicinema.R; 29 import com.xgimi.gimicinema.R;
29 import com.xgimi.gimicinema.mview.ISettingView; 30 import com.xgimi.gimicinema.mview.ISettingView;
@@ -34,8 +35,6 @@ import org.greenrobot.eventbus.EventBus; @@ -34,8 +35,6 @@ import org.greenrobot.eventbus.EventBus;
34 import java.util.ArrayList; 35 import java.util.ArrayList;
35 import java.util.HashMap; 36 import java.util.HashMap;
36 37
37 -import static com.qnbar.smc.service.SocketService.JUST_OPEN_DOOR;  
38 -  
39 /** 38 /**
40 * 设置类 39 * 设置类
41 * Created by pc on 2014/12/16. 40 * Created by pc on 2014/12/16.
@@ -337,7 +336,9 @@ public class SettingActivity extends BaseActivity implements ISettingView { @@ -337,7 +336,9 @@ public class SettingActivity extends BaseActivity implements ISettingView {
337 } 336 }
338 337
339 public void testOpenDoor(View view) { 338 public void testOpenDoor(View view) {
340 - openDoor(JUST_OPEN_DOOR, "setting test open door"); 339 + openDoor(SocketService.JUST_OPEN_DOOR, "setting test open door");
  340 +// PollingUtils.stopPollingService(this.getApplicationContext(), PollingServiceDemo.class, PollingService.ACTION);
  341 +// new SystemUtils().closeFtLed(this);;//test close led,could open by power
341 } 342 }
342 343
343 private void openDoor(int type, String msg) { 344 private void openDoor(int type, String msg) {
@@ -52,6 +52,7 @@ public class RoomInfoModelImpl implements IRoomInfoModel { @@ -52,6 +52,7 @@ public class RoomInfoModelImpl implements IRoomInfoModel {
52 @Override 52 @Override
53 public void onResponse(String response) { 53 public void onResponse(String response) {
54 RoomInfo roomInfo1 = null; 54 RoomInfo roomInfo1 = null;
  55 + Log.d("room-info", "getRoomInfo" +response);
55 try { 56 try {
56 roomInfo1 = new Gson().fromJson(response, RoomInfo.class); 57 roomInfo1 = new Gson().fromJson(response, RoomInfo.class);
57 } catch (JsonSyntaxException e) { 58 } catch (JsonSyntaxException e) {
@@ -85,6 +86,8 @@ public class RoomInfoModelImpl implements IRoomInfoModel { @@ -85,6 +86,8 @@ public class RoomInfoModelImpl implements IRoomInfoModel {
85 @Override 86 @Override
86 public void onResponse(String response) { 87 public void onResponse(String response) {
87 RoomStatusInfo roomInfo1 = null; 88 RoomStatusInfo roomInfo1 = null;
  89 + Log.d("room-info", "getRoomStatus" +response);
  90 +
88 try { 91 try {
89 roomInfo1 = new Gson().fromJson(response, RoomStatusInfo.class); 92 roomInfo1 = new Gson().fromJson(response, RoomStatusInfo.class);
90 } catch (JsonSyntaxException e) { 93 } catch (JsonSyntaxException e) {
@@ -115,6 +118,8 @@ public class RoomInfoModelImpl implements IRoomInfoModel { @@ -115,6 +118,8 @@ public class RoomInfoModelImpl implements IRoomInfoModel {
115 118
116 @Override 119 @Override
117 public void onResponse(String response) { 120 public void onResponse(String response) {
  121 + Log.d("room-info", "getRoomQrCode:" + response);
  122 +
118 RoomQrCodeInfo roomInfo1 = null; 123 RoomQrCodeInfo roomInfo1 = null;
119 try { 124 try {
120 roomInfo1 = new Gson().fromJson(response, RoomQrCodeInfo.class); 125 roomInfo1 = new Gson().fromJson(response, RoomQrCodeInfo.class);
@@ -146,7 +151,7 @@ public class RoomInfoModelImpl implements IRoomInfoModel { @@ -146,7 +151,7 @@ public class RoomInfoModelImpl implements IRoomInfoModel {
146 151
147 @Override 152 @Override
148 public void onResponse(String response) { 153 public void onResponse(String response) {
149 - Log.d("room-info", response); 154 + Log.d("room-info", "reportOpenDoorStatus:" + response);
150 listener.onOpenDoorSuccess(); 155 listener.onOpenDoorSuccess();
151 } 156 }
152 }); 157 });
  1 +/*
  2 + * Copyright (c) 2017. wugian
  3 + * Licensed under the Apache License, Version 2.0 (the "License");
  4 + * you may not use this file except in compliance with the License.
  5 + * You may obtain a copy of the License at
  6 + *
  7 + * http://www.apache.org/licenses/LICENSE-2.0
  8 + *
  9 + * Unless required by applicable law or agreed to in writing, software
  10 + * distributed under the License is distributed on an "AS IS" BASIS,
  11 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 + * See the License for the specific language governing permissions and
  13 + * limitations under the License.
  14 + *
  15 + */
  16 +
  17 +package com.xgimi.gimicinema.poll;
  18 +
  19 +import android.app.Service;
  20 +import android.content.Intent;
  21 +import android.os.IBinder;
  22 +import android.util.Log;
  23 +
  24 +/**
  25 + * PollingService Demo do something in PollingThread
  26 + */
  27 +public class PollingServiceDemo extends Service {
  28 + //name of this service action
  29 + public static final String ACTION = "com.qnbar.service.PollingServiceDemo";
  30 +
  31 + @Override
  32 + public IBinder onBind(Intent intent) {
  33 + return null;
  34 + }
  35 +
  36 + @Override
  37 + public void onCreate() {
  38 + Log.d("polling-demo", "onCreate");
  39 +// initNotifiManager();
  40 + }
  41 +
  42 + @Override
  43 + public int onStartCommand(Intent intent, int flags, int startId) {
  44 + Log.d("polling-demo", "onStartCommand");
  45 + new PollingThread().start();
  46 + return super.onStartCommand(intent, flags, startId);
  47 + }
  48 +
  49 + // @Override
  50 +// public void onStart(Intent intent, int startId) {
  51 +// new PollingThread().start();
  52 +// }
  53 +// //初始化通知栏配置
  54 +// private void initNotifiManager() {
  55 +// mManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
  56 +// int icon = R.drawable.ic_launcher;
  57 +// mNotification = new Notification();
  58 +// mNotification.icon = icon;
  59 +// mNotification.tickerText = "New Message";
  60 +// mNotification.defaults |= Notification.DEFAULT_SOUND;
  61 +// mNotification.flags = Notification.FLAG_AUTO_CANCEL;
  62 +// }
  63 +// //弹出Notification
  64 +// private void showNotification() {
  65 +// mNotification.when = System.currentTimeMillis();
  66 +// //Navigator to the new activity when click the notification title
  67 +// Intent i = new Intent(this, MessageActivity.class);
  68 +// PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, i,
  69 +// Intent.FLAG_ACTIVITY_NEW_TASK);
  70 +// mNotification.setLatestEventInfo(this,
  71 +// getResources().getString(R.string.app_name), "You have new message!", pendingIntent);
  72 +// mManager.notify(0, mNotification);
  73 +// }
  74 + /**
  75 + * Polling thread
  76 + * 模拟向Server轮询的异步线程
  77 + *
  78 + * @Author Ryan
  79 + * @Create 2013-7-13 上午10:18:34
  80 + */
  81 + int count = 0;
  82 +
  83 + class PollingThread extends Thread {
  84 + @Override
  85 + public void run() {
  86 + Log.d("polling-demo", "polling run");
  87 +// System.out.println("Polling...");
  88 + count++;
  89 + //当计数能被5整除时弹出通知
  90 +// if (count % 5 == 0) {
  91 +//// showNotification();
  92 +// System.out.println("New message!");
  93 +// }
  94 + }
  95 + }
  96 +
  97 + @Override
  98 + public void onDestroy() {
  99 + super.onDestroy();
  100 + Log.d("polling-demo", "onDestroy");
  101 +
  102 + System.out.println("Service:onDestroy");
  103 + }
  104 +}
@@ -256,21 +256,10 @@ public class MainPresenter extends BasePresenter @@ -256,21 +256,10 @@ public class MainPresenter extends BasePresenter
256 public void onGetRoomStatusSuccess(RoomStatusInfo info) { 256 public void onGetRoomStatusSuccess(RoomStatusInfo info) {
257 Log.d("room-info", "getOrderInfo#onGetRoomStatusSuccess:" + info.toString()); 257 Log.d("room-info", "getOrderInfo#onGetRoomStatusSuccess:" + info.toString());
258 RoomStatusInfo.DataEntity data = info.getData(); 258 RoomStatusInfo.DataEntity data = info.getData();
  259 + int offset = data.getNow_time() - data.getBegin_time();
259 int durationMinutes = data.getEnd_time() - data.getBegin_time(); 260 int durationMinutes = data.getEnd_time() - data.getBegin_time();
260 Log.d("CountService", "durationMinutes:" + durationMinutes); 261 Log.d("CountService", "durationMinutes:" + durationMinutes);
261 mainView.updateOrderInfo(info); 262 mainView.updateOrderInfo(info);
262 -// roomInfoModel.getRoomQrCode(data.getOrder_sn(), new RoomInfoModelImpl.GetRoomQrCodeListener() {  
263 -// @Override  
264 -// public void onGetRoomQrCodeSuccess(RoomQrCodeInfo info) {  
265 -// Log.d("room-info", "getOrderInfo#onGetRoomStatusSuccess#onGetRoomQrCodeSuccess:" + info.toString());  
266 -// mainView.prepareRoomQrCodeInfo(info);  
267 -// }  
268 -//  
269 -// @Override  
270 -// public void onGetRoomQrCodeFailure(WrongMsg wrongMsg) {  
271 -// Log.d("room-info", "onGetRoomQrCodeFailure:" + wrongMsg.toString());  
272 -// }  
273 -// });  
274 } 263 }
275 264
276 @Override 265 @Override
@@ -24,6 +24,8 @@ import android.os.IBinder; @@ -24,6 +24,8 @@ import android.os.IBinder;
24 import android.os.RemoteException; 24 import android.os.RemoteException;
25 import android.util.Log; 25 import android.util.Log;
26 import android.widget.Toast; 26 import android.widget.Toast;
  27 +import com.gimi.common.cinema.model.Constant;
  28 +import com.gimi.common.cinema.model.MessageEvent;
27 import com.gimi.common.cinema.utils.Utils; 29 import com.gimi.common.cinema.utils.Utils;
28 import com.qnbar.smc.model.Light; 30 import com.qnbar.smc.model.Light;
29 import com.qnbar.smc.model.Lights; 31 import com.qnbar.smc.model.Lights;
@@ -32,10 +34,13 @@ import com.telink.bluetooth.light.ConnectionStatus; @@ -32,10 +34,13 @@ import com.telink.bluetooth.light.ConnectionStatus;
32 import com.telink.bluetooth.light.DeviceInfo; 34 import com.telink.bluetooth.light.DeviceInfo;
33 import com.xgimi.gimicinema.ICinemaControl; 35 import com.xgimi.gimicinema.ICinemaControl;
34 import com.xgimi.gimicinema.application.FangTangApplication; 36 import com.xgimi.gimicinema.application.FangTangApplication;
  37 +import org.greenrobot.eventbus.EventBus;
35 38
36 import java.util.ArrayList; 39 import java.util.ArrayList;
37 import java.util.List; 40 import java.util.List;
38 41
  42 +import static com.xgimi.gimicinema.service.CountService.COUNT_DOWN_ZERO;
  43 +
39 public class CinemaControlService extends Service { 44 public class CinemaControlService extends Service {
40 private static final int LIGHT_MIN_VALUE = 5; 45 private static final int LIGHT_MIN_VALUE = 5;
41 private ArrayList<String> movies = new ArrayList<>(); 46 private ArrayList<String> movies = new ArrayList<>();
@@ -95,6 +100,7 @@ public class CinemaControlService extends Service { @@ -95,6 +100,7 @@ public class CinemaControlService extends Service {
95 switch (state) { 100 switch (state) {
96 case 0://空闲 101 case 0://空闲
97 fadeIn(); 102 fadeIn();
  103 + showQrCodeRightNow();
98 // msgEvent.setEventId(0x19910); 104 // msgEvent.setEventId(0x19910);
99 // msgEvent.setMessage("open_switch"); 105 // msgEvent.setMessage("open_switch");
100 // EventBus.getDefault().post(msgEvent); 106 // EventBus.getDefault().post(msgEvent);
@@ -313,4 +319,13 @@ public class CinemaControlService extends Service { @@ -313,4 +319,13 @@ public class CinemaControlService extends Service {
313 // params = new byte[]{0x05, (byte) value}; 319 // params = new byte[]{0x05, (byte) value};
314 // TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true); 320 // TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true);
315 } 321 }
  322 +
  323 + private void showQrCodeRightNow() {
  324 + Constant.count = -1;
  325 +// PollingUtils.stopPollingService();
  326 + MessageEvent messageEvent = new MessageEvent();
  327 + messageEvent.setEventId(COUNT_DOWN_ZERO);
  328 + messageEvent.setMessage("记数为0");
  329 + EventBus.getDefault().post(messageEvent);
  330 + }
316 } 331 }
Please register or login to post a comment