Commit 387577ba0363a00b424d298565391db2d18aaf7d

Authored by Penley
1 parent 4b342aa3

lights fix ,some other bug fix

... ... @@ -268,8 +268,9 @@ public class LocalMovieScanUtils {
268 268 String curPath = curFiles.getAbsoluteFile().toString();
269 269 LocalMovieMessage moviesItem = new LocalMovieMessage();
270 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 274 String media = getMedia(curPath + "/", mediaExtensions);
274 275 String poster;
275 276 poster = MovieMessageUtils.getLocalMoviePoster(curPath);
... ...
... ... @@ -91,7 +91,7 @@ public class DeviceSettingActivity extends Activity implements OnClickListener {
91 91
92 92 TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, immediate);
93 93 }
94   - }
  94 + }
95 95 };
96 96 private int meshAddress;
97 97
... ...
... ... @@ -151,7 +151,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
151 151 mApplication.doInit();
152 152 setContentView(R.layout.a_main);
153 153 initLight();
154   -// initLock();
  154 + initLock();
155 155 context = this;
156 156 mData = new ArrayList<>();
157 157 clazzData = new ArrayList<>();
... ...
... ... @@ -18,6 +18,7 @@ package com.xgimi.gimicinema.model;
18 18 import android.content.Context;
19 19 import android.content.SharedPreferences;
20 20 import android.os.Handler;
  21 +
21 22 import com.gimi.common.cinema.db.NewDBManager;
22 23 import com.gimi.common.cinema.model.Constant;
23 24 import com.gimi.common.cinema.model.LocalMovieMessage;
... ... @@ -78,7 +79,7 @@ public class MovieListModelImpl implements IMovieListModel {
78 79 list = dbManager.queryType(keyword, queryType,
79 80 SourceType.values()[index]);
80 81 }
81   - if (list.size() > 0) {
  82 + if (list != null && list.size() >= 0) {
82 83 MovieListModelImpl.this.handleSuccess(listener, list);
83 84 } else {
84 85 MovieListModelImpl.this.handleFailure(listener);
... ...
... ... @@ -636,8 +636,8 @@ public class AskService extends Service implements IAskView {
636 636
637 637 @Override
638 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 641 Log.d(TAG, "delay time change reset");
642 642 boolean reset = intent.getBooleanExtra("reset", false);
643 643 if (statusPool != null) {
... ...
... ... @@ -16,12 +16,12 @@
16 16
17 17 package com.xgimi.gimicinema.service;
18 18
19   -import android.app.ActivityManager;
20 19 import android.app.Service;
21 20 import android.content.ComponentName;
22 21 import android.content.Context;
23 22 import android.content.Intent;
24 23 import android.content.ServiceConnection;
  24 +import android.os.Handler;
25 25 import android.os.IBinder;
26 26 import android.os.RemoteException;
27 27 import android.util.Log;
... ... @@ -31,7 +31,6 @@ import com.xgimi.gimicinema.ICinemaControl;
31 31 import com.xgimi.gimicinema.ICinemaSMC;
32 32
33 33 import java.util.ArrayList;
34   -import java.util.Iterator;
35 34 import java.util.List;
36 35
37 36 public class CinemaControlService extends Service {
... ... @@ -84,13 +83,16 @@ public class CinemaControlService extends Service {
84 83 Log.d("aidl", "state change cinemaSMC not null");
85 84 switch (state) {
86 85 case 0:
87   - open();
  86 +// open();
  87 + fadeIn();
88 88 break;
89 89 case 1:
90   - close();
  90 + fadeOut();
  91 +// close();
91 92 break;
92 93 case 2:
93   - open();
  94 +// open();
  95 + fadeIn();
94 96 break;
95 97 }
96 98 }
... ... @@ -130,12 +132,51 @@ public class CinemaControlService extends Service {
130 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 173 @Override
134 174 public void onCreate() {
135 175 super.onCreate();
136 176 if (!mBound) {
137 177 attemptToBindService();
138 178 }
  179 +
139 180 }
140 181
141 182 @Override
... ... @@ -173,31 +214,31 @@ public class CinemaControlService extends Service {
173 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 243 private void open() {
203 244 byte opcode = (byte) 0xD0;
... ... @@ -215,6 +256,32 @@ public class CinemaControlService extends Service {
215 256 if (TelinkLightService.Instance().sendCommandNoResponse(opcode, address, params)) {
216 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