Showing
8 changed files
with
100 additions
and
328 deletions
| ... | ... | @@ -42,6 +42,7 @@ public class SocketService extends Service { |
| 42 | 42 | 10009 //已经认证过了,不允许再认证 |
| 43 | 43 | */ |
| 44 | 44 | private static final int SUCCESS_MESSAGE = 10000; |
| 45 | + private static final int CONTAIN_MESSAGE = 10001; | |
| 45 | 46 | private static final int AUTHENTICATION_FAILED = 10002; //连接(认证)失败 |
| 46 | 47 | private static final int CONNECTION_BEFORE_AUTHENTICATION = 10003;//还未注册连接就进行认证 |
| 47 | 48 | private static final int NOT_SEND_ROOM_SN = 10004;//终端编号未传 |
| ... | ... | @@ -262,8 +263,8 @@ public class SocketService extends Service { |
| 262 | 263 | sendMsg(msg); |
| 263 | 264 | } |
| 264 | 265 | break; |
| 265 | - case OPEN_DOOR: | |
| 266 | - if (socketResponse.getData() != null) { | |
| 266 | + case CONTAIN_MESSAGE: | |
| 267 | + if (socketResponse.getData() != null && socketResponse.getCmd() == OPEN_DOOR) { | |
| 267 | 268 | switch (socketResponse.getData().getUser()) { |
| 268 | 269 | //10用户,20管理员,默认值为0 |
| 269 | 270 | case 10: |
| ... | ... | @@ -288,12 +289,12 @@ public class SocketService extends Service { |
| 288 | 289 | default: |
| 289 | 290 | Log.d(TAG, "print msg:" + socketResponse.toString()); |
| 290 | 291 | } |
| 291 | - if (("openDoor").equals(socketResponse.getCmd())) { | |
| 292 | - MessageEvent messageEvent = new MessageEvent(); | |
| 293 | - messageEvent.setEventId(JUST_OPEN_DOOR); | |
| 294 | - messageEvent.setMessage("click item"); | |
| 295 | - EventBus.getDefault().post(messageEvent); | |
| 296 | - } | |
| 292 | +// if (("openDoor").equals(socketResponse.getCmd())) { | |
| 293 | +// MessageEvent messageEvent = new MessageEvent(); | |
| 294 | +// messageEvent.setEventId(JUST_OPEN_DOOR); | |
| 295 | +// messageEvent.setMessage("click item"); | |
| 296 | +// EventBus.getDefault().post(messageEvent); | |
| 297 | +// } | |
| 297 | 298 | } catch (JsonSyntaxException e) { |
| 298 | 299 | Log.d(TAG, message); |
| 299 | 300 | e.printStackTrace(); | ... | ... |
| 1 | 1 | package com.xgimi.gimicinema.activity; |
| 2 | 2 | |
| 3 | 3 | import android.app.Activity; |
| 4 | -import android.app.AlertDialog; | |
| 5 | -import android.content.DialogInterface; | |
| 6 | 4 | import android.content.Intent; |
| 7 | 5 | import android.os.Bundle; |
| 8 | -import android.view.KeyEvent; | |
| 9 | 6 | import android.view.MotionEvent; |
| 10 | -import com.gimi.common.cinema.model.Constant; | |
| 11 | -import com.gimi.common.cinema.utils.AuthUtils; | |
| 12 | 7 | import com.gimi.common.cinema.utils.LeeImageLoader; |
| 13 | 8 | import com.gimi.common.cinema.utils.SystemUtils; |
| 14 | -import com.gimi.common.cinema.utils.Utils; | |
| 15 | 9 | import com.umeng.analytics.MobclickAgent; |
| 16 | -import com.xgimi.gimicinema.BuildConfig; | |
| 17 | 10 | import com.xgimi.gimicinema.service.AskService; |
| 18 | 11 | |
| 19 | 12 | /** |
| ... | ... | @@ -23,15 +16,12 @@ public class BaseActivity extends Activity { |
| 23 | 16 | // public static final int THEME_DEFAULT = 1; |
| 24 | 17 | // public static final int THEME_GOOD = 2; |
| 25 | 18 | // public static final int THEME_THEME = 3; |
| 26 | - private AlertDialog alertDialog; | |
| 27 | - private int agentType; | |
| 28 | 19 | |
| 29 | 20 | @Override |
| 30 | 21 | protected void onCreate(Bundle savedInstanceState) { |
| 31 | 22 | // setBaseTheme(); |
| 32 | 23 | super.onCreate(savedInstanceState); |
| 33 | 24 | MobclickAgent.setDebugMode(true); |
| 34 | - agentType = Utils.getInt(Utils.getSp(this), "agent-type", 0); | |
| 35 | 25 | |
| 36 | 26 | } |
| 37 | 27 | |
| ... | ... | @@ -44,9 +34,6 @@ public class BaseActivity extends Activity { |
| 44 | 34 | protected void onDestroy() { |
| 45 | 35 | super.onDestroy(); |
| 46 | 36 | LeeImageLoader.clearCache(this); |
| 47 | - if (alertDialog != null) { | |
| 48 | - alertDialog.dismiss(); | |
| 49 | - } | |
| 50 | 37 | } |
| 51 | 38 | |
| 52 | 39 | // private void setBaseTheme() { |
| ... | ... | @@ -73,47 +60,11 @@ public class BaseActivity extends Activity { |
| 73 | 60 | // } |
| 74 | 61 | |
| 75 | 62 | |
| 76 | - protected void showDialog() { | |
| 77 | - if (alertDialog == null) { | |
| 78 | - AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
| 79 | - builder.setTitle("提示"); | |
| 80 | - builder.setMessage("点播时间已到,如有需要,请到前台续时"); | |
| 81 | - builder.setOnKeyListener(new DialogInterface.OnKeyListener() { | |
| 82 | - @Override | |
| 83 | - public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { | |
| 84 | - return keyCode == KeyEvent.KEYCODE_BACK; | |
| 85 | - } | |
| 86 | - }); | |
| 87 | - builder.setCancelable(false); | |
| 88 | - builder.setPositiveButton("确认", new DialogInterface.OnClickListener() { | |
| 89 | - @Override | |
| 90 | - public void onClick(DialogInterface dialog, int which) { | |
| 91 | - if (Constant.messageRun) { | |
| 92 | - dialog.dismiss(); | |
| 93 | - } else { | |
| 94 | - BaseActivity.this.finish(); | |
| 95 | - } | |
| 96 | - } | |
| 97 | - }); | |
| 98 | - alertDialog = builder.create(); | |
| 99 | - } | |
| 100 | - alertDialog.show(); | |
| 101 | - } | |
| 102 | - | |
| 103 | - | |
| 104 | 63 | @Override |
| 105 | 64 | protected void onResume() { |
| 106 | 65 | super.onResume(); |
| 107 | 66 | MobclickAgent.onResume(this); |
| 108 | 67 | bind(); |
| 109 | - if (agentType == 5 && AuthUtils.checkOfflineAuthTime(this)) { | |
| 110 | - return; | |
| 111 | - } | |
| 112 | - if (BuildConfig.MACHINE_TYPE.equals("himedia")) { | |
| 113 | - if (!Constant.messageRun) { | |
| 114 | - showDialog(); | |
| 115 | - } | |
| 116 | - } | |
| 117 | 68 | } |
| 118 | 69 | |
| 119 | 70 | @Override | ... | ... |
| ... | ... | @@ -197,6 +197,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
| 197 | 197 | |
| 198 | 198 | ImageView sourceTypeIv = (ImageView) findViewById(R.id.movie_source_type_iv); |
| 199 | 199 | controlQrCodeIv = (ImageView) findViewById(R.id.controlQrCode); |
| 200 | + controlQrCodeIv.setVisibility(View.GONE); | |
| 200 | 201 | recommendRv = (OrderRecyclerView) findViewById(R.id.recommend); |
| 201 | 202 | mainSearch = (Button) findViewById(R.id.mainSearch); |
| 202 | 203 | scrollView = (ScrollView) findViewById(R.id.scrollView); |
| ... | ... | @@ -236,13 +237,13 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
| 236 | 237 | presenter.load(this); |
| 237 | 238 | Intent intent = new Intent(this, SocketService.class); |
| 238 | 239 | startService(intent); |
| 239 | -// new Handler().postDelayed(new Runnable() { | |
| 240 | -// @Override | |
| 241 | -// public void run() { | |
| 242 | -// Log.d("room-info", "test open door report"); | |
| 243 | -// openDoor(); | |
| 244 | -// } | |
| 245 | -// }, 20 * 1000); | |
| 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); | |
| 246 | 247 | } |
| 247 | 248 | |
| 248 | 249 | @Override |
| ... | ... | @@ -360,30 +361,30 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
| 360 | 361 | |
| 361 | 362 | @Override |
| 362 | 363 | public void showUnauthorized() { |
| 363 | - AlertDialog.Builder builder = new AlertDialog.Builder(context); | |
| 364 | - builder.setTitle("提示"); | |
| 365 | - String promote = getString(R.string.unauthorized_promote); | |
| 366 | - if (BuildConfig.MACHINE_TYPE.equals("himedia")) { | |
| 367 | - promote += "串号:" + SystemUtils.getPid(context, BuildConfig.MACHINE_TYPE); | |
| 368 | - } | |
| 369 | - builder.setMessage(promote); | |
| 370 | - builder.setOnKeyListener(new DialogInterface.OnKeyListener() { | |
| 371 | - @Override | |
| 372 | - public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { | |
| 373 | - return keyCode == KeyEvent.KEYCODE_BACK; | |
| 374 | - } | |
| 375 | - }); | |
| 376 | - builder.setCancelable(false); | |
| 377 | - builder.setPositiveButton("确认", new DialogInterface.OnClickListener() { | |
| 378 | - @Override | |
| 379 | - public void onClick(DialogInterface dialog, int which) { | |
| 380 | - if (Constant.gimiAuth) { | |
| 381 | - dialog.dismiss(); | |
| 382 | - } else { | |
| 383 | - MainActivity.this.finish(); | |
| 384 | - } | |
| 385 | - } | |
| 386 | - }).show(); | |
| 364 | +// AlertDialog.Builder builder = new AlertDialog.Builder(context); | |
| 365 | +// builder.setTitle("提示"); | |
| 366 | +// String promote = getString(R.string.unauthorized_promote); | |
| 367 | +// if (BuildConfig.MACHINE_TYPE.equals("himedia")) { | |
| 368 | +// promote += "串号:" + SystemUtils.getPid(context, BuildConfig.MACHINE_TYPE); | |
| 369 | +// } | |
| 370 | +// builder.setMessage(promote); | |
| 371 | +// builder.setOnKeyListener(new DialogInterface.OnKeyListener() { | |
| 372 | +// @Override | |
| 373 | +// public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { | |
| 374 | +// return keyCode == KeyEvent.KEYCODE_BACK; | |
| 375 | +// } | |
| 376 | +// }); | |
| 377 | +// builder.setCancelable(false); | |
| 378 | +// builder.setPositiveButton("确认", new DialogInterface.OnClickListener() { | |
| 379 | +// @Override | |
| 380 | +// public void onClick(DialogInterface dialog, int which) { | |
| 381 | +// if (Constant.gimiAuth) { | |
| 382 | +// dialog.dismiss(); | |
| 383 | +// } else { | |
| 384 | +// MainActivity.this.finish(); | |
| 385 | +// } | |
| 386 | +// } | |
| 387 | +// }).show(); | |
| 387 | 388 | } |
| 388 | 389 | |
| 389 | 390 | @Override |
| ... | ... | @@ -506,7 +507,8 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
| 506 | 507 | } |
| 507 | 508 | Log.d("room-info", "report the open door status"); |
| 508 | 509 | if (roomStatusInfo == null || roomStatusInfo.getData() == null) { |
| 509 | - presenter.reportOpenDoorStatus("123456"); | |
| 510 | +// presenter.reportOpenDoorStatus("123456"); | |
| 511 | + Log.d("room-info", "report room status null"); | |
| 510 | 512 | } else { |
| 511 | 513 | presenter.reportOpenDoorStatus(roomStatusInfo.getData().getOrder_sn()); |
| 512 | 514 | } |
| ... | ... | @@ -519,6 +521,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
| 519 | 521 | @Override |
| 520 | 522 | public void prepareRoomQrCodeInfo(RoomQrCodeInfo info) { |
| 521 | 523 | this.info = info; |
| 524 | + startActivity(new Intent(this, QrCodeShowActivity.class).putExtra("qr", info.getData().getCode())); | |
| 522 | 525 | } |
| 523 | 526 | |
| 524 | 527 | @Override |
| ... | ... | @@ -1030,20 +1033,20 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
| 1030 | 1033 | if (info == null || info.getData() == null) { |
| 1031 | 1034 | break; |
| 1032 | 1035 | } |
| 1033 | - startActivity(new Intent(this, QrCodeShowActivity.class).putExtra("qr", info.getData().getCode())); | |
| 1036 | + presenter.getCleanQrCode(roomStatusInfo.getData().getOrder_sn()); | |
| 1034 | 1037 | // startActivity(new Intent(this, QrCodeShowActivity.class).putExtra("qr", "updateOrderInfo")); |
| 1035 | 1038 | break; |
| 1036 | 1039 | } |
| 1037 | 1040 | } |
| 1038 | 1041 | |
| 1039 | 1042 | private void openDoor() { |
| 1043 | + Log.d("room-info", "openDoor called"); | |
| 1040 | 1044 | bleBroadcastReceiver.setResponseObj(new GREENCITYBLEProtocolFactory.GREENCITYBleDataWritten() { |
| 1041 | 1045 | |
| 1042 | 1046 | @Override |
| 1043 | 1047 | public void writeSuccess() { |
| 1044 | 1048 | bleBroadcastReceiver.setResponseObj(null); |
| 1045 | 1049 | Toast.makeText(MainActivity.this, "开门成功", Toast.LENGTH_SHORT).show(); |
| 1046 | - | |
| 1047 | 1050 | BLEOpenRecord bleOpenRecord = new BLEOpenRecord(); |
| 1048 | 1051 | bleOpenRecord.setLockmac(lockMac); |
| 1049 | 1052 | bleOpenRecord.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(new Date())); |
| ... | ... | @@ -1052,7 +1055,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
| 1052 | 1055 | intent.putExtra("openrecord", bleOpenRecord); |
| 1053 | 1056 | sendBroadcast(intent); |
| 1054 | 1057 | Log.d("room-info", "open success"); |
| 1055 | - handler.post(reportRunnable); | |
| 1058 | + handler.postDelayed(reportRunnable, 30 * 1000); | |
| 1056 | 1059 | } |
| 1057 | 1060 | |
| 1058 | 1061 | @Override | ... | ... |
| ... | ... | @@ -39,6 +39,7 @@ public class RoomInfoModelImpl implements IRoomInfoModel { |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | + Log.d("room-info", "request:getRoomInfo,url = " + ROOM_INFO_BY_IMEI_URL + imei); | |
| 42 | 43 | OkHttpClientManager.getAsyn(ROOM_INFO_BY_IMEI_URL + imei, |
| 43 | 44 | new OkHttpClientManager.ResultCallback<String>() { |
| 44 | 45 | @Override |
| ... | ... | @@ -71,6 +72,7 @@ public class RoomInfoModelImpl implements IRoomInfoModel { |
| 71 | 72 | |
| 72 | 73 | @Override |
| 73 | 74 | public void getRoomStatus(String roomSn, final GetRoomStatusListener listener) { |
| 75 | + Log.d("room-info", "request:getRoomStatus,url = " + ROOM_STATUS_BY_ROOM_SN_URL + roomSn); | |
| 74 | 76 | OkHttpClientManager.getAsyn(ROOM_STATUS_BY_ROOM_SN_URL + roomSn, |
| 75 | 77 | new OkHttpClientManager.ResultCallback<String>() { |
| 76 | 78 | @Override |
| ... | ... | @@ -101,6 +103,7 @@ public class RoomInfoModelImpl implements IRoomInfoModel { |
| 101 | 103 | |
| 102 | 104 | @Override |
| 103 | 105 | public void getRoomQrCode(String orderSn, final GetRoomQrCodeListener listener) { |
| 106 | + Log.d("room-info", "request:getRoomQrCode,url = " + ROOM_QRCODE_BY_ORDER_SN + orderSn); | |
| 104 | 107 | OkHttpClientManager.getAsyn(ROOM_QRCODE_BY_ORDER_SN + orderSn, |
| 105 | 108 | new OkHttpClientManager.ResultCallback<String>() { |
| 106 | 109 | @Override |
| ... | ... | @@ -132,16 +135,18 @@ public class RoomInfoModelImpl implements IRoomInfoModel { |
| 132 | 135 | |
| 133 | 136 | @Override |
| 134 | 137 | public void reportOpenDoorStatus(String orderSn, final OpenDoorStatusListener listener) { |
| 138 | + Log.d("room-info", "request:reportOpenDoorStatus,url = " + ROOM_QRCODE_BY_ORDER_SN + orderSn); | |
| 135 | 139 | OkHttpClientManager.getAsyn(ROOM_REPORT_ROOM_STATUS + orderSn, |
| 136 | 140 | new OkHttpClientManager.ResultCallback<String>() { |
| 137 | 141 | @Override |
| 138 | 142 | public void onError(Request request, Exception e) { |
| 143 | + Log.d("room-info", request.toString() + "," + e.getMessage()); | |
| 139 | 144 | listener.onOpenDoorFailure(); |
| 140 | 145 | } |
| 141 | 146 | |
| 142 | 147 | @Override |
| 143 | 148 | public void onResponse(String response) { |
| 144 | - Log.d("cccccc", response); | |
| 149 | + Log.d("room-info", response); | |
| 145 | 150 | listener.onOpenDoorSuccess(); |
| 146 | 151 | } |
| 147 | 152 | }); | ... | ... |
| ... | ... | @@ -22,13 +22,11 @@ import android.text.TextUtils; |
| 22 | 22 | import android.util.Log; |
| 23 | 23 | import android.widget.Toast; |
| 24 | 24 | import com.gimi.common.cinema.model.ClassificationItem; |
| 25 | -import com.gimi.common.cinema.model.Constant; | |
| 26 | 25 | import com.gimi.common.cinema.model.LocalMovieMessage; |
| 27 | 26 | import com.gimi.common.cinema.model.RoomInfo; |
| 28 | 27 | import com.gimi.common.cinema.model.RoomQrCodeInfo; |
| 29 | 28 | import com.gimi.common.cinema.model.RoomStatusInfo; |
| 30 | 29 | import com.gimi.common.cinema.model.WrongMsg; |
| 31 | -import com.gimi.common.cinema.utils.AuthUtils; | |
| 32 | 30 | import com.gimi.common.cinema.utils.LocalDataUtils; |
| 33 | 31 | import com.gimi.common.cinema.utils.SambaFileCharge; |
| 34 | 32 | import com.gimi.common.cinema.utils.SystemUtils; |
| ... | ... | @@ -91,7 +89,7 @@ public class MainPresenter extends BasePresenter |
| 91 | 89 | |
| 92 | 90 | public void load(final Context context) { |
| 93 | 91 | this.context = context; |
| 94 | - loadCtrl(context); | |
| 92 | +// loadCtrl(context); | |
| 95 | 93 | mountSamba(context); |
| 96 | 94 | loadRecommend(context); |
| 97 | 95 | loadClassification(context); |
| ... | ... | @@ -261,18 +259,18 @@ public class MainPresenter extends BasePresenter |
| 261 | 259 | int durationMinutes = data.getEnd_time() - data.getBegin_time(); |
| 262 | 260 | Log.d("CountService", "durationMinutes:" + durationMinutes); |
| 263 | 261 | mainView.updateOrderInfo(info); |
| 264 | - roomInfoModel.getRoomQrCode(data.getOrder_sn(), new RoomInfoModelImpl.GetRoomQrCodeListener() { | |
| 265 | - @Override | |
| 266 | - public void onGetRoomQrCodeSuccess(RoomQrCodeInfo info) { | |
| 267 | - Log.d("room-info", "getOrderInfo#onGetRoomStatusSuccess#onGetRoomQrCodeSuccess:" + info.toString()); | |
| 268 | - mainView.prepareRoomQrCodeInfo(info); | |
| 269 | - } | |
| 270 | - | |
| 271 | - @Override | |
| 272 | - public void onGetRoomQrCodeFailure(WrongMsg wrongMsg) { | |
| 273 | - Log.d("room-info", "onGetRoomQrCodeFailure:" + wrongMsg.toString()); | |
| 274 | - } | |
| 275 | - }); | |
| 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 | +// }); | |
| 276 | 274 | } |
| 277 | 275 | |
| 278 | 276 | @Override |
| ... | ... | @@ -294,6 +292,22 @@ public class MainPresenter extends BasePresenter |
| 294 | 292 | }); |
| 295 | 293 | } |
| 296 | 294 | |
| 295 | + public void getCleanQrCode(String orderSn) { | |
| 296 | + roomInfoModel.getRoomQrCode(orderSn, new RoomInfoModelImpl.GetRoomQrCodeListener() { | |
| 297 | + @Override | |
| 298 | + public void onGetRoomQrCodeSuccess(RoomQrCodeInfo info) { | |
| 299 | + Log.d("room-info", "getCleanQrCode#onGetRoomQrCodeSuccess:" + info.toString()); | |
| 300 | + mainView.prepareRoomQrCodeInfo(info); | |
| 301 | + } | |
| 302 | + | |
| 303 | + @Override | |
| 304 | + public void onGetRoomQrCodeFailure(WrongMsg wrongMsg) { | |
| 305 | + Log.d("room-info", "onGetRoomQrCodeFailure:" + wrongMsg.toString()); | |
| 306 | + } | |
| 307 | + }); | |
| 308 | + } | |
| 309 | + | |
| 310 | + | |
| 297 | 311 | @Override |
| 298 | 312 | public void onGetControlImageSuccess(Bitmap bitmap) { |
| 299 | 313 | mainView.loadCtrlImg(bitmap); |
| ... | ... | @@ -346,17 +360,17 @@ public class MainPresenter extends BasePresenter |
| 346 | 360 | } |
| 347 | 361 | |
| 348 | 362 | public void checkAuth() { |
| 349 | - if (new SystemUtils().getYbProp() == 3 || Utils.getInt(context, "agent-type", 0) == 5) { | |
| 350 | - return; | |
| 351 | - } | |
| 352 | - if (!Constant.gimiAuth) { | |
| 353 | - mainView.showUnauthorized(); | |
| 354 | - } | |
| 355 | - if (!AuthUtils.checkOfflineAuthTime(context)) { | |
| 356 | - if (AuthUtils.isFinish(context)) { | |
| 357 | - mainView.showUnauthorizedTimeOut(); | |
| 358 | - } | |
| 359 | - } | |
| 363 | +// if (new SystemUtils().getYbProp() == 3 || Utils.getInt(context, "agent-type", 0) == 5) { | |
| 364 | +// return; | |
| 365 | +// } | |
| 366 | +// if (!Constant.gimiAuth) { | |
| 367 | +// mainView.showUnauthorized(); | |
| 368 | +// } | |
| 369 | +// if (!AuthUtils.checkOfflineAuthTime(context)) { | |
| 370 | +// if (AuthUtils.isFinish(context)) { | |
| 371 | +// mainView.showUnauthorizedTimeOut(); | |
| 372 | +// } | |
| 373 | +// } | |
| 360 | 374 | |
| 361 | 375 | |
| 362 | 376 | } | ... | ... |
| ... | ... | @@ -23,7 +23,6 @@ import android.content.IntentFilter; |
| 23 | 23 | import android.content.SharedPreferences; |
| 24 | 24 | import android.net.ConnectivityManager; |
| 25 | 25 | import android.net.NetworkInfo; |
| 26 | - | |
| 27 | 26 | import com.gimi.common.cinema.model.Constant; |
| 28 | 27 | import com.gimi.common.cinema.utils.SystemUtils; |
| 29 | 28 | import com.gimi.common.cinema.utils.WifiApManger; |
| ... | ... | @@ -98,11 +97,11 @@ public class BootReceiver extends BroadcastReceiver { |
| 98 | 97 | Intent intents = new Intent(context, AskService.class); |
| 99 | 98 | context.startService(intents); |
| 100 | 99 | } |
| 101 | - if (startOpen && !Constant.userOpen) { | |
| 102 | - Intent openIntent = new Intent(context, StartActivity.class); | |
| 103 | - openIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
| 104 | - context.startActivity(openIntent); | |
| 105 | - } | |
| 100 | +// if (startOpen && !Constant.userOpen) { | |
| 101 | + Intent openIntent = new Intent(context, StartActivity.class); | |
| 102 | + openIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
| 103 | + context.startActivity(openIntent); | |
| 104 | +// } | |
| 106 | 105 | if (openAp) { |
| 107 | 106 | WifiApManger.openWifiAp(context); |
| 108 | 107 | } | ... | ... |
| 1 | 1 | package com.xgimi.gimicinema.service; |
| 2 | 2 | |
| 3 | 3 | import android.app.Service; |
| 4 | -import android.content.ComponentName; | |
| 5 | 4 | import android.content.Context; |
| 6 | 5 | import android.content.Intent; |
| 7 | -import android.content.ServiceConnection; | |
| 8 | 6 | import android.content.SharedPreferences; |
| 9 | 7 | import android.os.Handler; |
| 10 | 8 | import android.os.IBinder; |
| 11 | -import android.os.Message; | |
| 12 | -import android.os.RemoteException; | |
| 13 | -import android.text.TextUtils; | |
| 14 | -import android.util.Log; | |
| 15 | 9 | import android.widget.Toast; |
| 16 | 10 | import com.gimi.common.cinema.db.NewDBManager; |
| 17 | -import com.gimi.common.cinema.model.BaseData; | |
| 18 | 11 | import com.gimi.common.cinema.model.Constant; |
| 19 | -import com.gimi.common.cinema.model.ControlMessage; | |
| 20 | -import com.gimi.common.cinema.model.GimiMessage; | |
| 21 | -import com.gimi.common.cinema.model.GimiSysMsg; | |
| 22 | -import com.gimi.common.cinema.model.PlayStatus; | |
| 23 | -import com.gimi.common.cinema.model.PlayStatusMessage; | |
| 24 | 12 | import com.gimi.common.cinema.model.SambaMsg; |
| 25 | -import com.gimi.common.cinema.model.UdpModel; | |
| 26 | -import com.gimi.common.cinema.utils.AuthUtils; | |
| 27 | -import com.gimi.common.cinema.utils.FolderUtils; | |
| 28 | 13 | import com.gimi.common.cinema.utils.LocalDataUtils; |
| 29 | -import com.gimi.common.cinema.utils.MovieMessageUtils; | |
| 30 | 14 | import com.gimi.common.cinema.utils.OpenMMUtils; |
| 31 | -import com.gimi.common.cinema.utils.SambaFileCharge; | |
| 32 | 15 | import com.gimi.common.cinema.utils.SystemUtils; |
| 33 | -import com.gimi.common.cinema.utils.T; | |
| 34 | 16 | import com.gimi.common.cinema.utils.Utils; |
| 35 | -import com.google.gson.Gson; | |
| 36 | -import com.google.gson.GsonBuilder; | |
| 37 | -import com.xgimi.gimicinema.BuildConfig; | |
| 38 | -import com.xgimi.gimicinema.ICinemaControl; | |
| 39 | -import com.xgimi.gimicinema.activity.CinemaConfig; | |
| 40 | -import com.xgimi.gimicinema.deserializer.GimiMessageDeserializer; | |
| 41 | -import com.xgimi.gimicinema.deserializer.GimiSysMsgDeserializer; | |
| 42 | 17 | import com.xgimi.gimicinema.mview.IAskView; |
| 43 | 18 | import com.xgimi.gimicinema.presenter.AskPresenter; |
| 44 | 19 | |
| 45 | -import java.util.ArrayList; | |
| 46 | 20 | import java.util.List; |
| 47 | 21 | |
| 48 | 22 | |
| ... | ... | @@ -63,36 +37,20 @@ public class AskService extends Service implements IAskView { |
| 63 | 37 | private String folder = ""; |
| 64 | 38 | |
| 65 | 39 | private SambaMsg sambaMsg; |
| 66 | - private Gson gson; | |
| 67 | - private UdpPostSender sender; | |
| 40 | + | |
| 68 | 41 | @Override |
| 69 | 42 | public void onCreate() { |
| 70 | 43 | super.onCreate(); |
| 71 | 44 | context = this; |
| 72 | - if (!mBound) { | |
| 73 | - attemptToBindService(); | |
| 74 | - } | |
| 75 | - gson = new GsonBuilder() | |
| 76 | - .registerTypeAdapter(GimiSysMsg.class, new GimiSysMsgDeserializer()) | |
| 77 | - .registerTypeAdapter(GimiMessage.class, new GimiMessageDeserializer()) | |
| 78 | -// .registerTypeAdapter(typeStatus, new QnMsgDeserializer<StatusData>()) | |
| 79 | -// .registerTypeAdapter(typeMessage, new QnMsgDeserializer<List<MessageData>>()) | |
| 80 | - .create(); | |
| 81 | - | |
| 82 | 45 | askPresenter = new AskPresenter(this); |
| 83 | 46 | localDataUtils = new LocalDataUtils(context); |
| 84 | 47 | dbManager = new NewDBManager(this); |
| 85 | 48 | systemUtils = new SystemUtils(); |
| 86 | 49 | sharedPreferences = Utils.getSp(context); |
| 87 | 50 | agentType = Utils.getInt(sharedPreferences, "agent-type", 0); |
| 88 | - Log.d(TAG, "onCreate: " + BuildConfig.MACHINE_TYPE); | |
| 89 | 51 | updateMsg(); |
| 90 | - | |
| 91 | - sender = new UdpPostSender("", 53301, 53301, _handler); | |
| 92 | - | |
| 93 | 52 | askPresenter.load(context); |
| 94 | 53 | handler.postDelayed(updateRunnable, 5 * 1000); |
| 95 | -// PollingUtils.startPollingService(context, 60, CountService.class, CountService.STATUS_ACTION); | |
| 96 | 54 | } |
| 97 | 55 | |
| 98 | 56 | private void updateMsg() { |
| ... | ... | @@ -103,133 +61,8 @@ public class AskService extends Service implements IAskView { |
| 103 | 61 | |
| 104 | 62 | int agentType; |
| 105 | 63 | |
| 106 | - private Handler _handler = new Handler() { | |
| 107 | - @Override | |
| 108 | - public void dispatchMessage(Message msg) { | |
| 109 | - if (msg.what == UdpPostSender.MSG_PARSE_DATA) { | |
| 110 | - //maybe need delay | |
| 111 | - if (AuthUtils.isFinish(context)) { | |
| 112 | - return; | |
| 113 | - } | |
| 114 | - String obj = (String) msg.obj; | |
| 115 | - ControlMessage controlMessage = gson.fromJson(obj, ControlMessage.class); | |
| 116 | - UdpModel udpModel1 = controlMessage.getUdpModel(); | |
| 117 | - switch (controlMessage.getAction()) { | |
| 118 | - case 0://播放点播电影 | |
| 119 | - playPath(getPlayUrl(udpModel1.getMovie_url())); | |
| 120 | - break; | |
| 121 | - case 1://播放点播电影列表 | |
| 122 | -// int length = udpModel1.getMovie_urls().length; | |
| 123 | -// String[] trans = new String[length]; | |
| 124 | -// for (int i = 0; i < length; i++) { | |
| 125 | -// trans[i] = getPlayUrl(udpModel1.getMovie_urls()[i]); | |
| 126 | -// } | |
| 127 | - playMultiPath(udpModel1.getMovie_urls(), udpModel1.getPosition()); | |
| 128 | - break; | |
| 129 | - case 2://返回当前播放状态 | |
| 130 | - try { | |
| 131 | - returnCurrentStatus(); | |
| 132 | - } catch (RemoteException e) { | |
| 133 | - e.printStackTrace(); | |
| 134 | - } | |
| 135 | - break; | |
| 136 | - } | |
| 137 | - } | |
| 138 | - super.dispatchMessage(msg); | |
| 139 | - } | |
| 140 | - }; | |
| 141 | - | |
| 142 | - private void returnCurrentStatus() throws RemoteException { | |
| 143 | - PlayStatusMessage statusMessage = new PlayStatusMessage(); | |
| 144 | - statusMessage.setAction(2); | |
| 145 | - PlayStatus status = new PlayStatus(); | |
| 146 | - status.setCurrentPosition(cinemaControl.getCurrentMoviePosition()); | |
| 147 | - status.setMovieLength(cinemaControl.getMovieDuration()); | |
| 148 | - status.setMovieUrls(cinemaControl.getPlayList()); | |
| 149 | - status.setPath(cinemaControl.getCurrentPath()); | |
| 150 | - status.setState(cinemaControl.getCurrentStatus()); | |
| 151 | - statusMessage.setStatus(status); | |
| 152 | - String s = gson.toJson(statusMessage); | |
| 153 | - sender.sendUDPmsg(s); | |
| 154 | - } | |
| 155 | - | |
| 156 | - private void playMultiPath(String[] movie_urls, int position) { | |
| 157 | - stopMediaPlayer(); | |
| 158 | - Toast.makeText(context.getApplicationContext(), | |
| 159 | - "即将播放新的列表电影", Toast.LENGTH_SHORT).show(); | |
| 160 | - List<String> result = new ArrayList<>(); | |
| 161 | - for (String movie_url : movie_urls) { | |
| 162 | - result.add("/mnt/samba/" + movie_url); | |
| 163 | - } | |
| 164 | - try { | |
| 165 | - cinemaControl.setPlayList(null); | |
| 166 | - cinemaControl.setPlayList(result); | |
| 167 | - } catch (RemoteException e) { | |
| 168 | - e.printStackTrace(); | |
| 169 | - } | |
| 170 | - playPath(result, position); | |
| 171 | - } | |
| 172 | - | |
| 173 | - | |
| 174 | - private String getPlayUrl(String url) { | |
| 175 | - String result; | |
| 176 | - if (BuildConfig.MACHINE_TYPE.equals("himedia")) { | |
| 177 | - String replace = url.replace(ip, ""); | |
| 178 | - if (!TextUtils.isEmpty(folder) && (replace.startsWith(folder) | |
| 179 | - || replace.startsWith("//" + folder) | |
| 180 | - || replace.startsWith("/" + folder))) { | |
| 181 | - replace = replace.replace(folder, ""); | |
| 182 | - } | |
| 183 | - result = (CinemaConfig.BASIC_ROOT + replace); | |
| 184 | - } else { | |
| 185 | - result = ("/mnt/samba/" + url); | |
| 186 | - } | |
| 187 | - return result; | |
| 188 | - } | |
| 189 | - | |
| 190 | 64 | private String currentPath = ""; |
| 191 | 65 | |
| 192 | - private void playPath(String videoPath) { | |
| 193 | - try { | |
| 194 | - cinemaControl.setPlayList(null); | |
| 195 | - } catch (RemoteException e) { | |
| 196 | - e.printStackTrace(); | |
| 197 | - } | |
| 198 | - if (!TextUtils.isEmpty(videoPath)) { | |
| 199 | - if (SambaFileCharge.fileExist(videoPath)) { | |
| 200 | - currentPath = videoPath; | |
| 201 | - BaseData bd = new BaseData(); | |
| 202 | - bd.setPath(videoPath); | |
| 203 | - stopMediaPlayer(); | |
| 204 | - Toast.makeText(context.getApplicationContext(), | |
| 205 | - "即将播放新的电影", Toast.LENGTH_SHORT).show(); | |
| 206 | - | |
| 207 | - final String path = bd.getPath(); | |
| 208 | - handler.postDelayed(new Runnable() { | |
| 209 | - @Override | |
| 210 | - public void run() { | |
| 211 | - askPresenter.playMovie(context, path); | |
| 212 | - } | |
| 213 | - }, 5000); | |
| 214 | - String movieFolderPath = FolderUtils.getMovieFolderPath(videoPath, sambaMsg.getIp(), null); | |
| 215 | - int playCount = MovieMessageUtils.getPlayCount(movieFolderPath); | |
| 216 | - playCount = playCount + 1; | |
| 217 | - MovieMessageUtils.writePlayCount(movieFolderPath, playCount);//update files | |
| 218 | - dbManager.updateMovieCount(videoPath, playCount); | |
| 219 | - } else { | |
| 220 | - T.show(context, "没有电影可以播放,请检查网络或者服务器情况"); | |
| 221 | - askPresenter.load(context); | |
| 222 | - updateMsg(); | |
| 223 | - } | |
| 224 | - } else { | |
| 225 | - T.show(context, "没有电影可以播放"); | |
| 226 | - } | |
| 227 | - } | |
| 228 | - | |
| 229 | - private void stopMediaPlayer() { | |
| 230 | - systemUtils.stopMediaPlayer(context.getApplicationContext()); | |
| 231 | - } | |
| 232 | - | |
| 233 | 66 | private Runnable updateRunnable = new Runnable() { |
| 234 | 67 | @Override |
| 235 | 68 | public void run() { |
| ... | ... | @@ -253,10 +86,6 @@ public class AskService extends Service implements IAskView { |
| 253 | 86 | @Override |
| 254 | 87 | public void onDestroy() { |
| 255 | 88 | askPresenter.umountSamba(); |
| 256 | - if (mBound) { | |
| 257 | - unbindService(mServiceConnection); | |
| 258 | - mBound = false; | |
| 259 | - } | |
| 260 | 89 | super.onDestroy(); |
| 261 | 90 | } |
| 262 | 91 | |
| ... | ... | @@ -274,35 +103,4 @@ public class AskService extends Service implements IAskView { |
| 274 | 103 | public void showMsg(String msg) { |
| 275 | 104 | Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); |
| 276 | 105 | } |
| 277 | - //由AIDL文件生成的Java类 | |
| 278 | - private ICinemaControl cinemaControl = null; | |
| 279 | - | |
| 280 | - //标志当前与服务端连接状况的布尔值,false为未连接,true为连接中 | |
| 281 | - private boolean mBound = false; | |
| 282 | - | |
| 283 | - | |
| 284 | - private ServiceConnection mServiceConnection = new ServiceConnection() { | |
| 285 | - @Override | |
| 286 | - public void onServiceConnected(ComponentName name, IBinder service) { | |
| 287 | - cinemaControl = ICinemaControl.Stub.asInterface(service); | |
| 288 | - mBound = true; | |
| 289 | - } | |
| 290 | - | |
| 291 | - @Override | |
| 292 | - public void onServiceDisconnected(ComponentName name) { | |
| 293 | - mBound = false; | |
| 294 | - } | |
| 295 | - }; | |
| 296 | - | |
| 297 | - /** | |
| 298 | - * 尝试与服务端建立连接 | |
| 299 | - */ | |
| 300 | - private void attemptToBindService() { | |
| 301 | - Intent intent = new Intent(); | |
| 302 | - intent.setAction("com.gimicinema.cinemacontrol"); | |
| 303 | - intent.setPackage("com.xgimi.gimicinema"); | |
| 304 | - bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE); | |
| 305 | - } | |
| 306 | - | |
| 307 | - public static final String ACTION = "cn.etzmico.broadcastreceiverregister.SENDBROADCAST"; | |
| 308 | 106 | } | ... | ... |
Please
register
or
login
to post a comment