Showing
2 changed files
with
18 additions
and
5 deletions
| ... | ... | @@ -62,6 +62,7 @@ import com.gimi.common.cinema.model.MessageEvent; |
| 62 | 62 | import com.gimi.common.cinema.utils.AuthUtils; |
| 63 | 63 | import com.gimi.common.cinema.utils.LeeImageLoader; |
| 64 | 64 | import com.gimi.common.cinema.utils.M1905Utils; |
| 65 | +import com.gimi.common.cinema.utils.NetStatusUtils; | |
| 65 | 66 | import com.gimi.common.cinema.utils.OpenMMUtils; |
| 66 | 67 | import com.gimi.common.cinema.utils.ScreenUtils; |
| 67 | 68 | import com.gimi.common.cinema.utils.SystemUtils; |
| ... | ... | @@ -1037,6 +1038,10 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
| 1037 | 1038 | show("没有配置智能幕布"); |
| 1038 | 1039 | return; |
| 1039 | 1040 | } |
| 1041 | + if (!NetStatusUtils.isAvailableByPing(mDeviceIp)) { | |
| 1042 | + show("没有找到智能幕布"); | |
| 1043 | + return; | |
| 1044 | + } | |
| 1040 | 1045 | messageThread = new MessageThread(); |
| 1041 | 1046 | |
| 1042 | 1047 | new Thread(messageThread).start(); | ... | ... |
| ... | ... | @@ -23,6 +23,7 @@ import android.os.Handler; |
| 23 | 23 | import android.os.IBinder; |
| 24 | 24 | import android.os.RemoteException; |
| 25 | 25 | import android.util.Log; |
| 26 | +import android.widget.Toast; | |
| 26 | 27 | import com.gimi.common.cinema.model.MessageEvent; |
| 27 | 28 | import com.gimi.common.cinema.utils.Utils; |
| 28 | 29 | import com.qnbar.smc.model.Light; |
| ... | ... | @@ -38,6 +39,7 @@ import java.util.ArrayList; |
| 38 | 39 | import java.util.List; |
| 39 | 40 | |
| 40 | 41 | public class CinemaControlService extends Service { |
| 42 | + private static final int LIGHT_MIN_VALUE = 5; | |
| 41 | 43 | private ArrayList<String> movies = new ArrayList<>(); |
| 42 | 44 | private long duration = 0; |
| 43 | 45 | private long currentPosition = 0; |
| ... | ... | @@ -175,7 +177,7 @@ public class CinemaControlService extends Service { |
| 175 | 177 | private Runnable openRunnable = new Runnable() { |
| 176 | 178 | @Override |
| 177 | 179 | public void run() { |
| 178 | - if (value++ == 10) { | |
| 180 | + if (value++ == LIGHT_MIN_VALUE) { | |
| 179 | 181 | open(); |
| 180 | 182 | handler.postDelayed(this, 2 * 1000); |
| 181 | 183 | } else { |
| ... | ... | @@ -255,6 +257,10 @@ public class CinemaControlService extends Service { |
| 255 | 257 | return; |
| 256 | 258 | } |
| 257 | 259 | Light byMeshAddress = Lights.getInstance().getByMeshAddress(connectDevice.meshAddress); |
| 260 | + if (byMeshAddress == null) { | |
| 261 | + Toast.makeText(context, "若智能灯光是出厂设置,请重新配置",Toast.LENGTH_SHORT).show(); | |
| 262 | + return; | |
| 263 | + } | |
| 258 | 264 | if (byMeshAddress.status == ConnectionStatus.ON) { |
| 259 | 265 | handler.removeCallbacks(closeRunnable); |
| 260 | 266 | return; |
| ... | ... | @@ -262,7 +268,7 @@ public class CinemaControlService extends Service { |
| 262 | 268 | maxValue = Utils.getInt(context, "brightness", 50); |
| 263 | 269 | // int status = mApplication.getConnectDevice().status; |
| 264 | 270 | // Log.d("status_charge", "fadeIn: " + status); |
| 265 | - value = 10; | |
| 271 | + value = LIGHT_MIN_VALUE; | |
| 266 | 272 | handler.post(openRunnable); |
| 267 | 273 | } |
| 268 | 274 | |
| ... | ... | @@ -273,6 +279,10 @@ public class CinemaControlService extends Service { |
| 273 | 279 | return; |
| 274 | 280 | } |
| 275 | 281 | Light byMeshAddress = Lights.getInstance().getByMeshAddress(connectDevice.meshAddress); |
| 282 | + if (byMeshAddress == null) { | |
| 283 | + Toast.makeText(context, "若智能灯光是出厂设置,请重新配置",Toast.LENGTH_SHORT).show(); | |
| 284 | + return; | |
| 285 | + } | |
| 276 | 286 | if (byMeshAddress.status == ConnectionStatus.OFF) { |
| 277 | 287 | handler.removeCallbacks(openRunnable); |
| 278 | 288 | return; |
| ... | ... | @@ -286,17 +296,15 @@ public class CinemaControlService extends Service { |
| 286 | 296 | } |
| 287 | 297 | |
| 288 | 298 | private void setLightValue(int value) { |
| 289 | - int addr = 0xFFFF; | |
| 299 | + int addr = 0xFFFF;//addr of all | |
| 290 | 300 | //change group brightness or color temperature |
| 291 | 301 | // addr = 0x8003; |
| 292 | 302 | byte opcode; |
| 293 | 303 | byte[] params; |
| 294 | - | |
| 295 | 304 | opcode = (byte) 0xD2; |
| 296 | 305 | params = new byte[]{(byte) value}; |
| 297 | 306 | TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true); |
| 298 | 307 | |
| 299 | - | |
| 300 | 308 | // opcode = (byte) 0xE2; |
| 301 | 309 | // params = new byte[]{0x05, (byte) value}; |
| 302 | 310 | // TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true); | ... | ... |
Please
register
or
login
to post a comment