Commit 387577ba0363a00b424d298565391db2d18aaf7d

Authored by Penley
1 parent 4b342aa3

lights fix ,some other bug fix

@@ -268,8 +268,9 @@ public class LocalMovieScanUtils { @@ -268,8 +268,9 @@ public class LocalMovieScanUtils {
268 String curPath = curFiles.getAbsoluteFile().toString(); 268 String curPath = curFiles.getAbsoluteFile().toString();
269 LocalMovieMessage moviesItem = new LocalMovieMessage(); 269 LocalMovieMessage moviesItem = new LocalMovieMessage();
270 String name = NameFilterUtils.getName(fileDir).trim(); 270 String name = NameFilterUtils.getName(fileDir).trim();
271 - moviesItem.setMovieName(name);  
272 - moviesItem.setNamePinyin(PinyinUtil.getAllFirstSpell(name)); 271 + moviesItem.setMovieName(name);String allFirstSpell = PinyinUtil.getAllFirstSpell(name);
  272 + String newStr = allFirstSpell.replaceAll("[^\\w,]", "");
  273 + moviesItem.setNamePinyin(newStr);
273 String media = getMedia(curPath + "/", mediaExtensions); 274 String media = getMedia(curPath + "/", mediaExtensions);
274 String poster; 275 String poster;
275 poster = MovieMessageUtils.getLocalMoviePoster(curPath); 276 poster = MovieMessageUtils.getLocalMoviePoster(curPath);
@@ -91,7 +91,7 @@ public class DeviceSettingActivity extends Activity implements OnClickListener { @@ -91,7 +91,7 @@ public class DeviceSettingActivity extends Activity implements OnClickListener {
91 91
92 TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, immediate); 92 TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, immediate);
93 } 93 }
94 - } 94 + }
95 }; 95 };
96 private int meshAddress; 96 private int meshAddress;
97 97
@@ -151,7 +151,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -151,7 +151,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
151 mApplication.doInit(); 151 mApplication.doInit();
152 setContentView(R.layout.a_main); 152 setContentView(R.layout.a_main);
153 initLight(); 153 initLight();
154 -// initLock(); 154 + initLock();
155 context = this; 155 context = this;
156 mData = new ArrayList<>(); 156 mData = new ArrayList<>();
157 clazzData = new ArrayList<>(); 157 clazzData = new ArrayList<>();
@@ -18,6 +18,7 @@ package com.xgimi.gimicinema.model; @@ -18,6 +18,7 @@ package com.xgimi.gimicinema.model;
18 import android.content.Context; 18 import android.content.Context;
19 import android.content.SharedPreferences; 19 import android.content.SharedPreferences;
20 import android.os.Handler; 20 import android.os.Handler;
  21 +
21 import com.gimi.common.cinema.db.NewDBManager; 22 import com.gimi.common.cinema.db.NewDBManager;
22 import com.gimi.common.cinema.model.Constant; 23 import com.gimi.common.cinema.model.Constant;
23 import com.gimi.common.cinema.model.LocalMovieMessage; 24 import com.gimi.common.cinema.model.LocalMovieMessage;
@@ -78,7 +79,7 @@ public class MovieListModelImpl implements IMovieListModel { @@ -78,7 +79,7 @@ public class MovieListModelImpl implements IMovieListModel {
78 list = dbManager.queryType(keyword, queryType, 79 list = dbManager.queryType(keyword, queryType,
79 SourceType.values()[index]); 80 SourceType.values()[index]);
80 } 81 }
81 - if (list.size() > 0) { 82 + if (list != null && list.size() >= 0) {
82 MovieListModelImpl.this.handleSuccess(listener, list); 83 MovieListModelImpl.this.handleSuccess(listener, list);
83 } else { 84 } else {
84 MovieListModelImpl.this.handleFailure(listener); 85 MovieListModelImpl.this.handleFailure(listener);
@@ -636,8 +636,8 @@ public class AskService extends Service implements IAskView { @@ -636,8 +636,8 @@ public class AskService extends Service implements IAskView {
636 636
637 @Override 637 @Override
638 public void onReceive(Context context, Intent intent) { 638 public void onReceive(Context context, Intent intent) {
639 - Toast.makeText(context, "myReceiver receive", Toast.LENGTH_SHORT)  
640 - .show(); 639 +// Toast.makeText(context, "myReceiver receive", Toast.LENGTH_SHORT)
  640 +// .show();
641 Log.d(TAG, "delay time change reset"); 641 Log.d(TAG, "delay time change reset");
642 boolean reset = intent.getBooleanExtra("reset", false); 642 boolean reset = intent.getBooleanExtra("reset", false);
643 if (statusPool != null) { 643 if (statusPool != null) {
@@ -16,12 +16,12 @@ @@ -16,12 +16,12 @@
16 16
17 package com.xgimi.gimicinema.service; 17 package com.xgimi.gimicinema.service;
18 18
19 -import android.app.ActivityManager;  
20 import android.app.Service; 19 import android.app.Service;
21 import android.content.ComponentName; 20 import android.content.ComponentName;
22 import android.content.Context; 21 import android.content.Context;
23 import android.content.Intent; 22 import android.content.Intent;
24 import android.content.ServiceConnection; 23 import android.content.ServiceConnection;
  24 +import android.os.Handler;
25 import android.os.IBinder; 25 import android.os.IBinder;
26 import android.os.RemoteException; 26 import android.os.RemoteException;
27 import android.util.Log; 27 import android.util.Log;
@@ -31,7 +31,6 @@ import com.xgimi.gimicinema.ICinemaControl; @@ -31,7 +31,6 @@ import com.xgimi.gimicinema.ICinemaControl;
31 import com.xgimi.gimicinema.ICinemaSMC; 31 import com.xgimi.gimicinema.ICinemaSMC;
32 32
33 import java.util.ArrayList; 33 import java.util.ArrayList;
34 -import java.util.Iterator;  
35 import java.util.List; 34 import java.util.List;
36 35
37 public class CinemaControlService extends Service { 36 public class CinemaControlService extends Service {
@@ -84,13 +83,16 @@ public class CinemaControlService extends Service { @@ -84,13 +83,16 @@ public class CinemaControlService extends Service {
84 Log.d("aidl", "state change cinemaSMC not null"); 83 Log.d("aidl", "state change cinemaSMC not null");
85 switch (state) { 84 switch (state) {
86 case 0: 85 case 0:
87 - open(); 86 +// open();
  87 + fadeIn();
88 break; 88 break;
89 case 1: 89 case 1:
90 - close(); 90 + fadeOut();
  91 +// close();
91 break; 92 break;
92 case 2: 93 case 2:
93 - open(); 94 +// open();
  95 + fadeIn();
94 break; 96 break;
95 } 97 }
96 } 98 }
@@ -130,12 +132,51 @@ public class CinemaControlService extends Service { @@ -130,12 +132,51 @@ public class CinemaControlService extends Service {
130 public CinemaControlService() { 132 public CinemaControlService() {
131 } 133 }
132 134
  135 + private int value;
  136 + private Handler handler = new Handler();
  137 + private Runnable closeRunnable = new Runnable() {
  138 + @Override
  139 + public void run() {
  140 + setLightValue(value);
  141 + if (value-- == 50) {
  142 + handler.postDelayed(this, 4 * 1000);
  143 + } else {
  144 + if (value == 0) {
  145 + handler.postDelayed(new Runnable() {
  146 + @Override
  147 + public void run() {
  148 + close();
  149 + }
  150 + }, 3 * 1000);
  151 + } else {
  152 + handler.postDelayed(this, 200);
  153 + }
  154 + }
  155 + }
  156 + };
  157 +
  158 + private Runnable openRunnable = new Runnable() {
  159 + @Override
  160 + public void run() {
  161 + if (value++ == 0) {
  162 + open();
  163 + handler.postDelayed(this, 4 * 1000);
  164 + } else {
  165 + setLightValue(value);
  166 + if (value != 50) {
  167 + handler.postDelayed(this, 200);
  168 + }
  169 + }
  170 + }
  171 + };
  172 +
133 @Override 173 @Override
134 public void onCreate() { 174 public void onCreate() {
135 super.onCreate(); 175 super.onCreate();
136 if (!mBound) { 176 if (!mBound) {
137 attemptToBindService(); 177 attemptToBindService();
138 } 178 }
  179 +
139 } 180 }
140 181
141 @Override 182 @Override
@@ -173,31 +214,31 @@ public class CinemaControlService extends Service { @@ -173,31 +214,31 @@ public class CinemaControlService extends Service {
173 bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE); 214 bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
174 } 215 }
175 216
176 - private boolean isSMCRun(Context context) {  
177 - return isServiceRunning(context, "com.qnbar.smc.service.SMCService");  
178 - }  
179 -  
180 - private boolean isServiceRunning(Context context, String className) {  
181 - ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);  
182 - boolean isRunning = false;  
183 - List serviceList = activityManager.getRunningServices(2147483647);  
184 - if (serviceList.size() <= 0) {  
185 - return false;  
186 - } else {  
187 - Iterator i$ = serviceList.iterator();  
188 -  
189 - while (i$.hasNext()) {  
190 - ActivityManager.RunningServiceInfo aServiceList = (ActivityManager.RunningServiceInfo) i$.next();  
191 - if (aServiceList.service.getClassName().equals(className)) {  
192 - isRunning = true;  
193 - break;  
194 - }  
195 - }  
196 -  
197 - Log.i("SystemUtils", "service is running?==" + isRunning);  
198 - return isRunning;  
199 - }  
200 - } 217 +// private boolean isSMCRun(Context context) {
  218 +// return isServiceRunning(context, "com.qnbar.smc.service.SMCService");
  219 +// }
  220 +//
  221 +// private boolean isServiceRunning(Context context, String className) {
  222 +// ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
  223 +// boolean isRunning = false;
  224 +// List serviceList = activityManager.getRunningServices(2147483647);
  225 +// if (serviceList.size() <= 0) {
  226 +// return false;
  227 +// } else {
  228 +// Iterator i$ = serviceList.iterator();
  229 +//
  230 +// while (i$.hasNext()) {
  231 +// ActivityManager.RunningServiceInfo aServiceList = (ActivityManager.RunningServiceInfo) i$.next();
  232 +// if (aServiceList.service.getClassName().equals(className)) {
  233 +// isRunning = true;
  234 +// break;
  235 +// }
  236 +// }
  237 +//
  238 +// Log.i("SystemUtils", "service is running?==" + isRunning);
  239 +// return isRunning;
  240 +// }
  241 +// }
201 242
202 private void open() { 243 private void open() {
203 byte opcode = (byte) 0xD0; 244 byte opcode = (byte) 0xD0;
@@ -215,6 +256,32 @@ public class CinemaControlService extends Service { @@ -215,6 +256,32 @@ public class CinemaControlService extends Service {
215 if (TelinkLightService.Instance().sendCommandNoResponse(opcode, address, params)) { 256 if (TelinkLightService.Instance().sendCommandNoResponse(opcode, address, params)) {
216 // show("open all success"); 257 // show("open all success");
217 } 258 }
  259 + }
  260 +
  261 + private void fadeIn() {
  262 + value = 0;
  263 + handler.post(openRunnable);
  264 + }
  265 +
  266 + private void fadeOut() {
  267 + value = 50;
  268 + handler.post(closeRunnable);
  269 + }
  270 +
  271 + private void setLightValue(int value) {
  272 + int addr = 0xFFFF;
  273 + //change group brightness or color temperature
  274 +// addr = 0x8003;
  275 + byte opcode;
  276 + byte[] params;
  277 +
  278 + opcode = (byte) 0xD2;
  279 + params = new byte[]{(byte) value};
  280 + TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true);
  281 +
218 282
  283 + opcode = (byte) 0xE2;
  284 + params = new byte[]{0x05, (byte) value};
  285 + TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true);
219 } 286 }
220 } 287 }
Please register or login to post a comment