Commit 43179bdd891896f679ef37ac342e2c0531196e53

Authored by 李攀
1 parent baaf8a93

fix search ,light and server status,scan ,admin player movie

@@ -41,4 +41,6 @@ interface ICinemaControl { @@ -41,4 +41,6 @@ interface ICinemaControl {
41 void openLight(); 41 void openLight();
42 42
43 void closeLight(); 43 void closeLight();
  44 +
  45 + void setUserControl(boolean userOperate);
44 } 46 }
@@ -9,6 +9,7 @@ import android.util.Log; @@ -9,6 +9,7 @@ import android.util.Log;
9 import com.gimi.common.cinema.model.LocalMovieMessage; 9 import com.gimi.common.cinema.model.LocalMovieMessage;
10 import com.gimi.common.cinema.model.QueryType; 10 import com.gimi.common.cinema.model.QueryType;
11 import com.gimi.common.cinema.model.SourceType; 11 import com.gimi.common.cinema.model.SourceType;
  12 +import com.gimi.common.cinema.utils.LogUtils;
12 import com.xgimi.gimicinema.activity.CinemaConfig; 13 import com.xgimi.gimicinema.activity.CinemaConfig;
13 14
14 import java.io.File; 15 import java.io.File;
@@ -170,6 +171,32 @@ public class NewDBManager { @@ -170,6 +171,32 @@ public class NewDBManager {
170 return result; 171 return result;
171 } 172 }
172 173
  174 + /**
  175 + * 利用事务批量添加本地数据,存在的数据不再更新,不存在的直接插入
  176 + *
  177 + * @param localMovieMessageList lst
  178 + * @return boolean
  179 + */
  180 + public boolean addByTransaction(List<LocalMovieMessage> localMovieMessageList) {
  181 + boolean result = false;
  182 + LogUtils.i("scan-time Transaction", System.currentTimeMillis() + "");
  183 + db.beginTransaction(); //开始事务
  184 + try {
  185 + for (int i = 0; i < localMovieMessageList.size(); i++) {
  186 + ContentValues values = constructCv(localMovieMessageList.get(i));
  187 + db.insertWithOnConflict(NewDBHelper.TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
  188 + }
  189 + db.setTransactionSuccessful();
  190 + result = true;
  191 + } catch (Exception e) {
  192 + e.printStackTrace();
  193 + } finally {
  194 + db.endTransaction(); //结束事务
  195 + }
  196 + LogUtils.i("scan-time Transaction", System.currentTimeMillis() + ":" + result);
  197 + return result;
  198 + }
  199 +
173 public void deleteFileNotExists() { 200 public void deleteFileNotExists() {
174 List<LocalMovieMessage> result = query(); 201 List<LocalMovieMessage> result = query();
175 for (LocalMovieMessage lmm : result) 202 for (LocalMovieMessage lmm : result)
@@ -604,7 +631,7 @@ public class NewDBManager { @@ -604,7 +631,7 @@ public class NewDBManager {
604 } 631 }
605 keyBuffer.append("'");*/ 632 keyBuffer.append("'");*/
606 // Cursor c = db.rawQuery("SELECT * FROM movie_message where pinyin LIKE '%" + key + "%' order by length(pinyin) asc limit 0,20", null); 633 // Cursor c = db.rawQuery("SELECT * FROM movie_message where pinyin LIKE '%" + key + "%' order by length(pinyin) asc limit 0,20", null);
607 - String sql = "SELECT * FROM movie_message where pinyin LIKE " + "'%" + key + "%'" + " order by length(name) asc limit 20"; 634 + String sql = "SELECT * FROM movie_message where pinyin LIKE " + "'%" + key + "%'" + " order by length(name) asc limit 99";
608 Cursor c = db.rawQuery(sql, null); 635 Cursor c = db.rawQuery(sql, null);
609 readCursor2List(persons, c); 636 readCursor2List(persons, c);
610 c.close(); 637 c.close();
@@ -66,7 +66,7 @@ public class DbUpdateUtils { @@ -66,7 +66,7 @@ public class DbUpdateUtils {
66 //区分结束还是卡死 66 //区分结束还是卡死
67 callback.onMessage("已扫描:" + allLocalMovies.size()); 67 callback.onMessage("已扫描:" + allLocalMovies.size());
68 if (allLocalMovies.size() != 0) { 68 if (allLocalMovies.size() != 0) {
69 - dbManager.add(allLocalMovies); 69 + dbManager.addByTransaction(allLocalMovies);
70 callback.onSuccess(allLocalMovies.size()); 70 callback.onSuccess(allLocalMovies.size());
71 } else { 71 } else {
72 caught.setCode(0); 72 caught.setCode(0);
@@ -6,10 +6,12 @@ import android.content.ComponentName; @@ -6,10 +6,12 @@ import android.content.ComponentName;
6 import android.content.Context; 6 import android.content.Context;
7 import android.content.Intent; 7 import android.content.Intent;
8 import android.content.IntentFilter; 8 import android.content.IntentFilter;
  9 +import android.content.ServiceConnection;
9 import android.content.SharedPreferences; 10 import android.content.SharedPreferences;
10 import android.content.pm.PackageManager; 11 import android.content.pm.PackageManager;
11 import android.os.Handler; 12 import android.os.Handler;
12 import android.os.IBinder; 13 import android.os.IBinder;
  14 +import android.os.RemoteException;
13 import android.text.TextUtils; 15 import android.text.TextUtils;
14 import android.util.Log; 16 import android.util.Log;
15 import android.widget.Toast; 17 import android.widget.Toast;
@@ -52,6 +54,7 @@ import com.telink.bluetooth.light.Parameters; @@ -52,6 +54,7 @@ import com.telink.bluetooth.light.Parameters;
52 import com.telink.bluetooth.light.model.Mesh; 54 import com.telink.bluetooth.light.model.Mesh;
53 import com.telink.util.Event; 55 import com.telink.util.Event;
54 import com.telink.util.EventListener; 56 import com.telink.util.EventListener;
  57 +import com.xgimi.gimicinema.ICinemaControl;
55 import com.xgimi.gimicinema.R; 58 import com.xgimi.gimicinema.R;
56 import com.xgimi.gimicinema.activity.AdsPreVideoPlayerActivity; 59 import com.xgimi.gimicinema.activity.AdsPreVideoPlayerActivity;
57 import com.xgimi.gimicinema.activity.QrCodeShowActivity; 60 import com.xgimi.gimicinema.activity.QrCodeShowActivity;
@@ -59,6 +62,7 @@ import com.xgimi.gimicinema.activity.SimpleAdsPlayer2; @@ -59,6 +62,7 @@ import com.xgimi.gimicinema.activity.SimpleAdsPlayer2;
59 import com.xgimi.gimicinema.application.FangTangApplication; 62 import com.xgimi.gimicinema.application.FangTangApplication;
60 import com.xgimi.gimicinema.entity.Status; 63 import com.xgimi.gimicinema.entity.Status;
61 import com.xgimi.gimicinema.poll.PollingUtils; 64 import com.xgimi.gimicinema.poll.PollingUtils;
  65 +import com.xgimi.gimicinema.service.CinemaControlService;
62 import com.xgimi.gimicinema.service.CountService; 66 import com.xgimi.gimicinema.service.CountService;
63 import org.greenrobot.eventbus.EventBus; 67 import org.greenrobot.eventbus.EventBus;
64 import org.greenrobot.eventbus.Subscribe; 68 import org.greenrobot.eventbus.Subscribe;
@@ -85,6 +89,18 @@ public class SmartControlService extends BaseService implements EventListener<St @@ -85,6 +89,18 @@ public class SmartControlService extends BaseService implements EventListener<St
85 private boolean initGetOderInfo; 89 private boolean initGetOderInfo;
86 private RoomStatusInfo lastCompleteRoomStatusInfo; 90 private RoomStatusInfo lastCompleteRoomStatusInfo;
87 private int openDoorServerTime = 0; 91 private int openDoorServerTime = 0;
  92 + private ICinemaControl iPlayer = null;
  93 + private ServiceConnection conn = new ServiceConnection() {
  94 + public void onServiceConnected(ComponentName className, IBinder service) {
  95 + LogUtils.i("bind cinema control service success");
  96 + iPlayer = ICinemaControl.Stub.asInterface(service);
  97 + }
  98 +
  99 + public void onServiceDisconnected(ComponentName className) {
  100 + LogUtils.i("cinema control service error");
  101 + iPlayer = null;
  102 + }
  103 + };
88 104
89 private void initLock() { 105 private void initLock() {
90 // 检查当前手机是否支持ble 蓝牙,如果不支持退出程序 106 // 检查当前手机是否支持ble 蓝牙,如果不支持退出程序
@@ -101,6 +117,7 @@ public class SmartControlService extends BaseService implements EventListener<St @@ -101,6 +117,7 @@ public class SmartControlService extends BaseService implements EventListener<St
101 public void onCreate() { 117 public void onCreate() {
102 super.onCreate(); 118 super.onCreate();
103 Log.d(TAG, "onCreate"); 119 Log.d(TAG, "onCreate");
  120 + bindService(new Intent(SmartControlService.this, CinemaControlService.class), conn, Context.BIND_AUTO_CREATE);
104 } 121 }
105 122
106 @Override 123 @Override
@@ -321,6 +338,14 @@ public class SmartControlService extends BaseService implements EventListener<St @@ -321,6 +338,14 @@ public class SmartControlService extends BaseService implements EventListener<St
321 // if (info == null || info.getData() == null) { 338 // if (info == null || info.getData() == null) {
322 // break; 339 // break;
323 // } 340 // }
  341 + if (iPlayer != null) {
  342 + try {
  343 + // end user control
  344 + iPlayer.setUserControl(false);
  345 + } catch (RemoteException e) {
  346 + e.printStackTrace();
  347 + }
  348 + }
324 Log.i("room-info", "COUNT_DOWN_ZERO stop polling finish some activity,jump to qr code activity"); 349 Log.i("room-info", "COUNT_DOWN_ZERO stop polling finish some activity,jump to qr code activity");
325 try { 350 try {
326 PollingUtils.stopPollingService(this, CountService.class, CountService.STATUS_ACTION); 351 PollingUtils.stopPollingService(this, CountService.class, CountService.STATUS_ACTION);
@@ -367,9 +392,13 @@ public class SmartControlService extends BaseService implements EventListener<St @@ -367,9 +392,13 @@ public class SmartControlService extends BaseService implements EventListener<St
367 Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); 392 Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
368 } 393 }
369 LogUtils.i("room-info", messageEvent.getMessage()); 394 LogUtils.i("room-info", messageEvent.getMessage());
370 - Utils.saveString(this, "oder-play-completed", new Gson().toJson(roomStatusInfo));  
371 - roomStatusInfo = null;  
372 -// playEndAds(); 395 + String value = new Gson().toJson(roomStatusInfo);
  396 + if (!TextUtils.isEmpty(value)) {
  397 + LogUtils.i("room-info", "room status info is:" + value);
  398 + Utils.saveString(this, "oder-play-completed", value);
  399 + } else {
  400 + LogUtils.i("room-info", "room status info is null");
  401 + }
373 break; 402 break;
374 default: 403 default:
375 Log.d("room-info", messageEvent.getMessage()); 404 Log.d("room-info", messageEvent.getMessage());
@@ -712,6 +741,7 @@ public class SmartControlService extends BaseService implements EventListener<St @@ -712,6 +741,7 @@ public class SmartControlService extends BaseService implements EventListener<St
712 .putExtra("room_sn", roomInfo.getData().getRoom_sn()) 741 .putExtra("room_sn", roomInfo.getData().getRoom_sn())
713 .putExtra("order_sn", roomStatusInfo.getData().getOrder_sn()); 742 .putExtra("order_sn", roomStatusInfo.getData().getOrder_sn());
714 intentAds.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 743 intentAds.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  744 + roomStatusInfo = null;
715 startActivity(intentAds); 745 startActivity(intentAds);
716 } 746 }
717 } 747 }
@@ -113,7 +113,7 @@ public class SocketService1 extends BaseService { @@ -113,7 +113,7 @@ public class SocketService1 extends BaseService {
113 AtomicBoolean sendRegister = new AtomicBoolean(false); 113 AtomicBoolean sendRegister = new AtomicBoolean(false);
114 AtomicInteger heartBeatErrorCount = new AtomicInteger(0); 114 AtomicInteger heartBeatErrorCount = new AtomicInteger(0);
115 115
116 - public ICinemaControl iPlayer = null; 116 + private ICinemaControl iPlayer = null;
117 private ServiceConnection conn = new ServiceConnection() { 117 private ServiceConnection conn = new ServiceConnection() {
118 public void onServiceConnected(ComponentName className, IBinder service) { 118 public void onServiceConnected(ComponentName className, IBinder service) {
119 LogUtils.i("bind cinema control service success"); 119 LogUtils.i("bind cinema control service success");
@@ -122,6 +122,7 @@ public class SocketService1 extends BaseService { @@ -122,6 +122,7 @@ public class SocketService1 extends BaseService {
122 122
123 public void onServiceDisconnected(ComponentName className) { 123 public void onServiceDisconnected(ComponentName className) {
124 LogUtils.i("cinema control service error"); 124 LogUtils.i("cinema control service error");
  125 + iPlayer = null;
125 } 126 }
126 }; 127 };
127 128
@@ -646,15 +647,36 @@ public class SocketService1 extends BaseService { @@ -646,15 +647,36 @@ public class SocketService1 extends BaseService {
646 e.printStackTrace(); 647 e.printStackTrace();
647 } 648 }
648 649
649 - if (op == 1 && status == 2) { 650 + if (op == 1 && status == Status.PlayerStatus.PLAYER_PAUSE) {
650 Log.d("setEqu", "开始播放"); 651 Log.d("setEqu", "开始播放");
651 - ShellUtils.execCommand("input keyevent 23", false);  
652 - } else if (op == 2 && status == 1) { 652 + mHandler.removeCallbacks(resumeRunnable);
  653 + pressCenterKey();
  654 + } else if (op == 2 && status == Status.PlayerStatus.PLAYER_PLAY) {
653 Log.d("setEqu", "暂停播放"); 655 Log.d("setEqu", "暂停播放");
654 - ShellUtils.execCommand("input keyevent 23", false); 656 + mHandler.postDelayed(resumeRunnable, 3 * 60 * 1000);
  657 + pressCenterKey();
655 } 658 }
656 } 659 }
657 660
  661 + private void pressCenterKey() {
  662 + ShellUtils.execCommand("input keyevent 23", false);
  663 + }
  664 +
  665 + private Runnable resumeRunnable = new Runnable() {
  666 + @Override
  667 + public void run() {
  668 + if (iPlayer != null) {
  669 + try {
  670 + if (iPlayer.getCurrentStatus() == Status.PlayerStatus.PLAYER_PAUSE) {
  671 + pressCenterKey();
  672 + }
  673 + } catch (RemoteException e) {
  674 + e.printStackTrace();
  675 + }
  676 + }
  677 + }
  678 + };
  679 +
658 private void setEquipmentStatus(EquipmentControl equc) { 680 private void setEquipmentStatus(EquipmentControl equc) {
659 setLight(equc.getLightCtl()); 681 setLight(equc.getLightCtl());
660 playCtl(equc.getPlayCtl()); 682 playCtl(equc.getPlayCtl());
@@ -690,12 +712,13 @@ public class SocketService1 extends BaseService { @@ -690,12 +712,13 @@ public class SocketService1 extends BaseService {
690 } 712 }
691 713
692 public int getLightStatus() { 714 public int getLightStatus() {
693 - int lightStatus = 3; 715 + int lightStatus = 2;
694 try { 716 try {
695 DeviceInfo connectDevice = ((FangTangApplication) getApplication()). 717 DeviceInfo connectDevice = ((FangTangApplication) getApplication()).
696 getConnectDevice(); 718 getConnectDevice();
697 if (connectDevice == null) { 719 if (connectDevice == null) {
698 LogUtils.i(TAG, "connectDevice is null"); 720 LogUtils.i(TAG, "connectDevice is null");
  721 + lightStatus = 3;
699 return lightStatus; 722 return lightStatus;
700 } 723 }
701 ConnectionStatus stu = Lights.getInstance(). 724 ConnectionStatus stu = Lights.getInstance().
@@ -4,7 +4,6 @@ import android.content.BroadcastReceiver; @@ -4,7 +4,6 @@ import android.content.BroadcastReceiver;
4 import android.content.Context; 4 import android.content.Context;
5 import android.content.Intent; 5 import android.content.Intent;
6 import android.content.IntentFilter; 6 import android.content.IntentFilter;
7 -import android.media.AudioManager;  
8 import android.media.MediaPlayer; 7 import android.media.MediaPlayer;
9 import android.net.Uri; 8 import android.net.Uri;
10 import android.os.Bundle; 9 import android.os.Bundle;
@@ -27,8 +26,8 @@ public class AdsPreVideoPlayerActivity extends BaseActivity { @@ -27,8 +26,8 @@ public class AdsPreVideoPlayerActivity extends BaseActivity {
27 private String playUrl; 26 private String playUrl;
28 private String videoPath; 27 private String videoPath;
29 28
30 - private AudioManager audioManager;  
31 - private int streamVolume; 29 +// private AudioManager audioManager;
  30 +// private int streamVolume;
32 31
33 private int playCount = 1; 32 private int playCount = 1;
34 private int duration; 33 private int duration;
@@ -40,11 +39,11 @@ public class AdsPreVideoPlayerActivity extends BaseActivity { @@ -40,11 +39,11 @@ public class AdsPreVideoPlayerActivity extends BaseActivity {
40 protected void onCreate(Bundle savedInstanceState) { 39 protected void onCreate(Bundle savedInstanceState) {
41 super.onCreate(savedInstanceState); 40 super.onCreate(savedInstanceState);
42 setContentView(R.layout.a_pre_ads_player); 41 setContentView(R.layout.a_pre_ads_player);
43 - audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);  
44 - streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM);  
45 - if (audioManager != null) {  
46 - audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, 20, 0);  
47 - } 42 +// audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
  43 +// streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM);
  44 +// if (audioManager != null) {
  45 +// audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, 20, 0);
  46 +// }
48 playCount = Utils.getSp(this).getInt("play_count", 1); 47 playCount = Utils.getSp(this).getInt("play_count", 1);
49 videoView = (VideoView) findViewById(R.id.videoView); 48 videoView = (VideoView) findViewById(R.id.videoView);
50 timeCount = (TextView) findViewById(R.id.promoteTv); 49 timeCount = (TextView) findViewById(R.id.promoteTv);
@@ -115,10 +114,10 @@ public class AdsPreVideoPlayerActivity extends BaseActivity { @@ -115,10 +114,10 @@ public class AdsPreVideoPlayerActivity extends BaseActivity {
115 protected void onStop() { 114 protected void onStop() {
116 super.onStop(); 115 super.onStop();
117 Constant.isAdsOn = false; 116 Constant.isAdsOn = false;
118 - if (audioManager != null) {  
119 - audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, streamVolume, 0);  
120 - audioManager = null;  
121 - } 117 +// if (audioManager != null) {
  118 +// audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, streamVolume, 0);
  119 +// audioManager = null;
  120 +// }
122 playUrl = null; 121 playUrl = null;
123 videoView = null; 122 videoView = null;
124 System.gc(); 123 System.gc();
@@ -13,4 +13,32 @@ public class Status { @@ -13,4 +13,32 @@ public class Status {
13 public enum LightStatus { 13 public enum LightStatus {
14 LIGHT_IDLE, LIGHT_CONNECTED 14 LIGHT_IDLE, LIGHT_CONNECTED
15 } 15 }
  16 +
  17 + public class PlayerStatus {
  18 + public static final int PLAYER_IDLE = 0;
  19 + public static final int PLAYER_PLAY = 1;
  20 + public static final int PLAYER_PAUSE = 2;
  21 + }
  22 +
  23 + public enum PlayerStatusEnum {
  24 + PLAYER_IDLE(0), PLAYER_PLAY(1), PLAYER_PAUSE(2);
  25 +
  26 + private int index;
  27 +
  28 + PlayerStatusEnum(int idx) {
  29 + this.index = idx;
  30 + }
  31 +
  32 + public int getIndex() {
  33 + return index;
  34 + }
  35 + }
  36 +
  37 + public static void main(String[] args) {
  38 +// PlayerStatusEnum playerStatusEnum = PlayerStatusEnum.PLAYER_IDLE;
  39 +// switch (playerStatusEnum){
  40 +// case 0:
  41 +// break;
  42 +// }
  43 + }
16 } 44 }
@@ -76,8 +76,7 @@ public class DBUpdateModelImpl implements IDBUpdateModel { @@ -76,8 +76,7 @@ public class DBUpdateModelImpl implements IDBUpdateModel {
76 @Override 76 @Override
77 public void doSomeThing() { 77 public void doSomeThing() {
78 try { 78 try {
79 - dbManager.add(all);  
80 - dbManager.deleteFileNotExists(); 79 + dbManager.addByTransaction(all);
81 } catch (Exception e) { 80 } catch (Exception e) {
82 handler.post(new Runnable() { 81 handler.post(new Runnable() {
83 @Override 82 @Override
@@ -94,6 +93,12 @@ public class DBUpdateModelImpl implements IDBUpdateModel { @@ -94,6 +93,12 @@ public class DBUpdateModelImpl implements IDBUpdateModel {
94 l.insertSuccess(all.size()); 93 l.insertSuccess(all.size());
95 } 94 }
96 }); 95 });
  96 +
  97 + try {
  98 + dbManager.deleteFileNotExists();
  99 + } catch (Exception e) {
  100 + e.printStackTrace();
  101 + }
97 } 102 }
98 }); 103 });
99 } 104 }
@@ -35,6 +35,7 @@ import com.telink.bluetooth.light.ConnectionStatus; @@ -35,6 +35,7 @@ import com.telink.bluetooth.light.ConnectionStatus;
35 import com.telink.bluetooth.light.DeviceInfo; 35 import com.telink.bluetooth.light.DeviceInfo;
36 import com.xgimi.gimicinema.ICinemaControl; 36 import com.xgimi.gimicinema.ICinemaControl;
37 import com.xgimi.gimicinema.application.FangTangApplication; 37 import com.xgimi.gimicinema.application.FangTangApplication;
  38 +import com.xgimi.gimicinema.entity.Status;
38 import org.greenrobot.eventbus.EventBus; 39 import org.greenrobot.eventbus.EventBus;
39 40
40 import java.util.ArrayList; 41 import java.util.ArrayList;
@@ -48,8 +49,9 @@ public class CinemaControlService extends Service { @@ -48,8 +49,9 @@ public class CinemaControlService extends Service {
48 private int currentState = 0; 49 private int currentState = 0;
49 private String currentPath = null; 50 private String currentPath = null;
50 // private static final int SAVE_BEAT = 500; 51 // private static final int SAVE_BEAT = 500;
51 - private static final int SAVE_BEAT = 5;//default 50 52 + private static final int SAVE_BEAT = 50;//default 50
52 private int saveBeat = SAVE_BEAT; 53 private int saveBeat = SAVE_BEAT;
  54 + private boolean userControl = false;
53 55
54 private final ICinemaControl.Stub cinemaControl = new ICinemaControl.Stub() { 56 private final ICinemaControl.Stub cinemaControl = new ICinemaControl.Stub() {
55 57
@@ -73,10 +75,10 @@ public class CinemaControlService extends Service { @@ -73,10 +75,10 @@ public class CinemaControlService extends Service {
73 public void setCurrentMoviePosition(long duration) throws RemoteException { 75 public void setCurrentMoviePosition(long duration) throws RemoteException {
74 // Log.d("aidl", "setCurrentMoviePosition: " + duration); 76 // Log.d("aidl", "setCurrentMoviePosition: " + duration);
75 currentPosition = duration; 77 currentPosition = duration;
76 - if (saveBeat-- == 0) { 78 + if (!userControl && saveBeat-- == 0) {
77 //TODO 保存当前进度,需要时从保存位置开始播放,取消播放器播放记录功能 79 //TODO 保存当前进度,需要时从保存位置开始播放,取消播放器播放记录功能
78 // 播放一段时间确保状态为关闭 80 // 播放一段时间确保状态为关闭
79 -// saveBeat = SAVE_BEAT; 81 + saveBeat = SAVE_BEAT;
80 try { 82 try {
81 if (!fadeOuting && Lights.getInstance().getByMeshAddress( 83 if (!fadeOuting && Lights.getInstance().getByMeshAddress(
82 ((FangTangApplication) getApplication()).getConnectDevice().meshAddress).status 84 ((FangTangApplication) getApplication()).getConnectDevice().meshAddress).status
@@ -114,24 +116,19 @@ public class CinemaControlService extends Service { @@ -114,24 +116,19 @@ public class CinemaControlService extends Service {
114 // } 116 // }
115 // MessageEvent msgEvent = new MessageEvent(); 117 // MessageEvent msgEvent = new MessageEvent();
116 switch (state) { 118 switch (state) {
117 - case 0://空闲 119 + case Status.PlayerStatus.PLAYER_IDLE://空闲
118 fadeIn(); 120 fadeIn();
119 showQrCodeRightNow(); 121 showQrCodeRightNow();
120 -// msgEvent.setEventId(0x19910);  
121 -// msgEvent.setMessage("open_switch");  
122 -// EventBus.getDefault().post(msgEvent);  
123 break; 122 break;
124 - case 1://播放  
125 - fadeOut();  
126 -// msgEvent.setEventId(0x19910);  
127 -// msgEvent.setMessage("close_switch");  
128 -// EventBus.getDefault().post(msgEvent); 123 + case Status.PlayerStatus.PLAYER_PLAY://播放
  124 + if (!userControl) {
  125 + fadeOut();
  126 + }
129 break; 127 break;
130 - case 2://暂停  
131 -// fadeIn();  
132 -// msgEvent.setEventId(0x19910);  
133 -// msgEvent.setMessage("open_switch");  
134 -// EventBus.getDefault().post(msgEvent); 128 + case Status.PlayerStatus.PLAYER_PAUSE://暂停
  129 + if (!userControl) {
  130 + fadeIn();
  131 + }
135 break; 132 break;
136 } 133 }
137 } 134 }
@@ -140,15 +137,10 @@ public class CinemaControlService extends Service { @@ -140,15 +137,10 @@ public class CinemaControlService extends Service {
140 @Override 137 @Override
141 public void addPlayPath(String path) throws RemoteException { 138 public void addPlayPath(String path) throws RemoteException {
142 movies.add(path);//strict contract 139 movies.add(path);//strict contract
143 -// MessageEvent msgEvent = new MessageEvent();  
144 -// msgEvent.setEventId(0x19910);  
145 -// msgEvent.setMessage("open_switch");  
146 -// EventBus.getDefault().post(msgEvent);  
147 } 140 }
148 141
149 @Override 142 @Override
150 public void setCurrentPlayPath(String path) throws RemoteException { 143 public void setCurrentPlayPath(String path) throws RemoteException {
151 -// Log.d("aidl", "setCurrentPlayPath: " + path);  
152 CinemaControlService.this.currentPath = path; 144 CinemaControlService.this.currentPath = path;
153 FangTangApplication application = (FangTangApplication) getApplication(); 145 FangTangApplication application = (FangTangApplication) getApplication();
154 application.setCurrentPlayUrl(path); 146 application.setCurrentPlayUrl(path);
@@ -174,12 +166,19 @@ public class CinemaControlService extends Service { @@ -174,12 +166,19 @@ public class CinemaControlService extends Service {
174 } 166 }
175 167
176 public void openLight() throws RemoteException { 168 public void openLight() throws RemoteException {
  169 + userControl = true;
177 fadeIn(); 170 fadeIn();
178 } 171 }
179 172
180 public void closeLight() throws RemoteException { 173 public void closeLight() throws RemoteException {
  174 + userControl = true;
181 fadeOut(); 175 fadeOut();
182 } 176 }
  177 +
  178 + @Override
  179 + public void setUserControl(boolean userOperate) throws RemoteException {
  180 + userControl = userOperate;
  181 + }
183 }; 182 };
184 183
185 public CinemaControlService() { 184 public CinemaControlService() {
@@ -198,11 +197,11 @@ public class CinemaControlService extends Service { @@ -198,11 +197,11 @@ public class CinemaControlService extends Service {
198 public void run() { 197 public void run() {
199 setLightValue(value); 198 setLightValue(value);
200 if (value-- == maxValue) { 199 if (value-- == maxValue) {
201 - handler.postDelayed(this, 4 * 1000); 200 + handler.postDelayed(this, 2 * 1000);
202 } else { 201 } else {
203 if (value == 0) { 202 if (value == 0) {
204 //how to remove 203 //how to remove
205 - handler.postDelayed(doClose, 3 * 1000); 204 + handler.postDelayed(doClose, 2 * 1000);
206 } else { 205 } else {
207 handler.postDelayed(this, 80); 206 handler.postDelayed(this, 80);
208 } 207 }
@@ -286,12 +285,7 @@ public class CinemaControlService extends Service { @@ -286,12 +285,7 @@ public class CinemaControlService extends Service {
286 setLightValue(maxValue); 285 setLightValue(maxValue);
287 return; 286 return;
288 } 287 }
289 -// int status = mApplication.getConnectDevice().status;  
290 -// Log.d("status_charge", "fadeIn: " + status);  
291 value = LIGHT_MIN_VALUE; 288 value = LIGHT_MIN_VALUE;
292 -// if (byMeshAddress.brightness > value) {  
293 -// value = byMeshAddress.brightness;  
294 -// }  
295 handler.post(openRunnable); 289 handler.post(openRunnable);
296 } 290 }
297 291
@@ -317,9 +311,6 @@ public class CinemaControlService extends Service { @@ -317,9 +311,6 @@ public class CinemaControlService extends Service {
317 return; 311 return;
318 } 312 }
319 maxValue = Utils.getInt(context, "brightness", 50); 313 maxValue = Utils.getInt(context, "brightness", 50);
320 -  
321 -// int status = connectDevice.status;  
322 -// Log.d("status_charge", "fadeOut: " + status);  
323 value = maxValue; 314 value = maxValue;
324 handler.post(closeRunnable); 315 handler.post(closeRunnable);
325 } 316 }
@@ -337,7 +328,6 @@ public class CinemaControlService extends Service { @@ -337,7 +328,6 @@ public class CinemaControlService extends Service {
337 } else { 328 } else {
338 Log.d("aidl", "set value failure:" + (TelinkLightService.Instance() != null)); 329 Log.d("aidl", "set value failure:" + (TelinkLightService.Instance() != null));
339 } 330 }
340 -  
341 // opcode = (byte) 0xE2; 331 // opcode = (byte) 0xE2;
342 // params = new byte[]{0x05, (byte) value}; 332 // params = new byte[]{0x05, (byte) value};
343 // TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true); 333 // TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true);
@@ -345,6 +335,7 @@ public class CinemaControlService extends Service { @@ -345,6 +335,7 @@ public class CinemaControlService extends Service {
345 335
346 private void showQrCodeRightNow() { 336 private void showQrCodeRightNow() {
347 if (duration - currentPosition < 1000 * 60) { 337 if (duration - currentPosition < 1000 * 60) {
  338 + userControl = false;
348 MessageEvent messageEvent = new MessageEvent(); 339 MessageEvent messageEvent = new MessageEvent();
349 messageEvent.setEventId(SmartControlService.ORDER_PLAY_COMPLETE); 340 messageEvent.setEventId(SmartControlService.ORDER_PLAY_COMPLETE);
350 messageEvent.setMessage("电影播放完成,记录完成订单信息"); 341 messageEvent.setMessage("电影播放完成,记录完成订单信息");
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 -<LinearLayout  
3 - xmlns:android="http://schemas.android.com/apk/res/android"  
4 - xmlns:tools="http://schemas.android.com/tools"  
5 - android:layout_width="match_parent"  
6 - android:layout_height="match_parent"  
7 - android:orientation="vertical"  
8 - android:gravity="center"  
9 - android:background="@color/white"  
10 - tools:context="com.xgimi.gimicinema.activity.QrCodeShowActivity"> 2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + android:layout_width="match_parent"
  5 + android:layout_height="match_parent"
  6 + android:background="@color/white"
  7 + android:gravity="center"
  8 + android:orientation="vertical"
  9 + tools:context="com.xgimi.gimicinema.activity.QrCodeShowActivity">
11 10
12 - <ImageView android:layout_width="400dp"  
13 - android:id="@+id/qrCodeIv"  
14 - android:layout_height="400dp"/> 11 + <ImageView
  12 + android:id="@+id/qrCodeIv"
  13 + android:layout_width="300dp"
  14 + android:layout_height="300dp" />
15 15
16 - <TextView android:layout_width="wrap_content"  
17 - android:layout_height="wrap_content"  
18 - android:textSize="30sp"  
19 - android:textColor="@color/black"  
20 - android:text="打扫完成后请扫二维码确认"/> 16 + <TextView
  17 + android:layout_width="wrap_content"
  18 + android:layout_height="wrap_content"
  19 + android:text="打扫完成后请扫二维码确认"
  20 + android:textColor="@color/black"
  21 + android:textSize="30sp" />
21 22
22 23
23 </LinearLayout> 24 </LinearLayout>
Please register or login to post a comment