Showing
7 changed files
with
154 additions
and
111 deletions
| ... | ... | @@ -97,19 +97,6 @@ public class MainActivity extends Activity implements EventListener<String> { |
| 97 | 97 | |
| 98 | 98 | requestWindowFeature(Window.FEATURE_NO_TITLE); |
| 99 | 99 | setContentView(R.layout.activity_main); |
| 100 | -// TelinkLog.d("-------------------------------------------"); | |
| 101 | -// TelinkLog.d(Build.MANUFACTURER); | |
| 102 | -// TelinkLog.d(Build.TYPE); | |
| 103 | -// TelinkLog.d(Build.BOOTLOADER); | |
| 104 | -// TelinkLog.d(Build.DEVICE); | |
| 105 | -// TelinkLog.d(Build.HARDWARE); | |
| 106 | -// TelinkLog.d(Build.SERIAL); | |
| 107 | -// TelinkLog.d(Build.BRAND); | |
| 108 | -// TelinkLog.d(Build.DISPLAY); | |
| 109 | -// TelinkLog.d(Build.FINGERPRINT); | |
| 110 | -// | |
| 111 | -// TelinkLog.d(Build.PRODUCT + ":" + Build.VERSION.SDK_INT + ":" + Build.VERSION.RELEASE + ":" + Build.VERSION.CODENAME + ":" + Build.ID); | |
| 112 | - | |
| 113 | 100 | IntentFilter filter = new IntentFilter(); |
| 114 | 101 | filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); |
| 115 | 102 | filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY - 1); | ... | ... |
| ... | ... | @@ -57,6 +57,7 @@ import com.xgimi.gimicinema.activity.AdsPreVideoPlayerActivity; |
| 57 | 57 | import com.xgimi.gimicinema.activity.QrCodeShowActivity; |
| 58 | 58 | import com.xgimi.gimicinema.activity.SimpleAdsPlayer2; |
| 59 | 59 | import com.xgimi.gimicinema.application.FangTangApplication; |
| 60 | +import com.xgimi.gimicinema.entity.Status; | |
| 60 | 61 | import com.xgimi.gimicinema.poll.PollingUtils; |
| 61 | 62 | import com.xgimi.gimicinema.service.CountService; |
| 62 | 63 | import org.greenrobot.eventbus.EventBus; |
| ... | ... | @@ -455,12 +456,14 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 455 | 456 | switch (deviceInfo.status) { |
| 456 | 457 | case LightAdapter.STATUS_LOGIN: |
| 457 | 458 | connectMeshAddress = mApplication.getConnectDevice().meshAddress; |
| 459 | + ((FangTangApplication) getApplication()).setLightStatus(Status.LightStatus.LIGHT_CONNECTED); | |
| 458 | 460 | show("灯光配对成功"); |
| 459 | 461 | break; |
| 460 | 462 | case LightAdapter.STATUS_CONNECTING: |
| 461 | 463 | show("与灯光配对"); |
| 462 | 464 | break; |
| 463 | 465 | case LightAdapter.STATUS_LOGOUT: |
| 466 | + ((FangTangApplication) getApplication()).setLightStatus(Status.LightStatus.LIGHT_IDLE); | |
| 464 | 467 | show("灯光断开"); |
| 465 | 468 | break; |
| 466 | 469 | default: | ... | ... |
| ... | ... | @@ -41,6 +41,7 @@ import com.xgimi.gimicinema.activity.MainActivity; |
| 41 | 41 | import com.xgimi.gimicinema.activity.QrCodeShowActivity; |
| 42 | 42 | import com.xgimi.gimicinema.activity.SimpleAdsPlayer2; |
| 43 | 43 | import com.xgimi.gimicinema.application.FangTangApplication; |
| 44 | +import com.xgimi.gimicinema.entity.Status; | |
| 44 | 45 | import com.xgimi.gimicinema.poll.PollingUtils; |
| 45 | 46 | import com.xgimi.gimicinema.service.CinemaControlService; |
| 46 | 47 | import com.xgimi.gimicinema.service.CountService; |
| ... | ... | @@ -240,6 +241,7 @@ public class SocketService1 extends BaseService { |
| 240 | 241 | if (socket != null && socket.isConnected()) { |
| 241 | 242 | return; |
| 242 | 243 | } |
| 244 | + ((FangTangApplication) getApplication()).setServerStatus(Status.ConnectServerStatus.SERVER_CONNECTING); | |
| 243 | 245 | boolean networkConnected = NetStatusUtils.isNetworkConnected(context); |
| 244 | 246 | boolean availableByPing = NetStatusUtils.isAvailableByPing("www.baidu.com"); |
| 245 | 247 | boolean availableByPing1 = NetStatusUtils.isAvailableByPing(serverHost); |
| ... | ... | @@ -350,6 +352,7 @@ public class SocketService1 extends BaseService { |
| 350 | 352 | |
| 351 | 353 | private synchronized void clearConnect() { |
| 352 | 354 | LogUtils.i(TAG, "clearConnect"); |
| 355 | + ((FangTangApplication) getApplication()).setServerStatus(Status.ConnectServerStatus.SERVER_IDLE); | |
| 353 | 356 | mHandler.removeCallbacks(heartBeatRunnable); |
| 354 | 357 | sendRegister.set(false); |
| 355 | 358 | heartBeatErrorCount.set(0); |
| ... | ... | @@ -427,6 +430,7 @@ public class SocketService1 extends BaseService { |
| 427 | 430 | LogUtils.i(TAG, "verify success start heart beat"); |
| 428 | 431 | break; |
| 429 | 432 | case HEART_BEAT_SUCCESS: |
| 433 | + ((FangTangApplication) getApplication()).setServerStatus(Status.ConnectServerStatus.SERVER_CONNECTED); | |
| 430 | 434 | LogUtils.d(TAG, "HEART_BEAT_SUCCESS,MainActivity Launched:" + ActivityCollector.isActivityExist(MainActivity.class)); |
| 431 | 435 | heartBeatErrorCount.set(0); |
| 432 | 436 | //每成功5次心跳判定是否启动main activity | ... | ... |
| ... | ... | @@ -37,6 +37,7 @@ import android.widget.Button; |
| 37 | 37 | import android.widget.ImageView; |
| 38 | 38 | import android.widget.RelativeLayout; |
| 39 | 39 | import android.widget.ScrollView; |
| 40 | +import android.widget.TextView; | |
| 40 | 41 | import android.widget.Toast; |
| 41 | 42 | import com.adroplat.fist_switch.jni.Device; |
| 42 | 43 | import com.adroplat.fist_switch.jni.FistJni; |
| ... | ... | @@ -57,6 +58,7 @@ import com.qnbar.smc.service.SmartControlService; |
| 57 | 58 | import com.qnbar.smc.service.SocketService1; |
| 58 | 59 | import com.qnbar.switchcontrol.model.SwitchMessageEvent; |
| 59 | 60 | import com.xgimi.gimicinema.R; |
| 61 | +import com.xgimi.gimicinema.application.FangTangApplication; | |
| 60 | 62 | import com.xgimi.gimicinema.mview.IMainView; |
| 61 | 63 | import com.xgimi.gimicinema.presenter.MainPresenter; |
| 62 | 64 | import com.xgimi.gimicinema.view.ClazzItem; |
| ... | ... | @@ -89,6 +91,7 @@ public class MainActivity extends BaseActivity implements IMainView/*, EventList |
| 89 | 91 | private Context context; |
| 90 | 92 | |
| 91 | 93 | private ImageView controlQrCodeIv; |
| 94 | + private TextView statusPromoteTv; | |
| 92 | 95 | private Button mainSearch; |
| 93 | 96 | private ScrollView scrollView; |
| 94 | 97 | private OrderRecyclerView recommendRv; |
| ... | ... | @@ -148,6 +151,7 @@ public class MainActivity extends BaseActivity implements IMainView/*, EventList |
| 148 | 151 | controlQrCodeIv = (ImageView) findViewById(R.id.controlQrCode); |
| 149 | 152 | controlQrCodeIv.setVisibility(View.GONE); |
| 150 | 153 | recommendRv = (OrderRecyclerView) findViewById(R.id.recommend); |
| 154 | + statusPromoteTv = (TextView) findViewById(R.id.statusPromote_tv); | |
| 151 | 155 | mainSearch = (Button) findViewById(R.id.mainSearch); |
| 152 | 156 | scrollView = (ScrollView) findViewById(R.id.scrollView); |
| 153 | 157 | clazzRv = (OrderRecyclerView) findViewById(R.id.classification); |
| ... | ... | @@ -199,20 +203,20 @@ public class MainActivity extends BaseActivity implements IMainView/*, EventList |
| 199 | 203 | } else { |
| 200 | 204 | Log.d("BaseService", "SmartControlService is running"); |
| 201 | 205 | } |
| 202 | -// initGetOrderInfo = true; | |
| 203 | -// presenter.getOrderInfo(); | |
| 204 | -// new Handler().postDelayed(new Runnable() { | |
| 205 | -// @Override | |
| 206 | -// public void run() { | |
| 207 | -// Log.d("room-info", "test open door report"); | |
| 208 | -// openDoor(); | |
| 209 | -// } | |
| 210 | -// }, 5 * 1000); | |
| 211 | - | |
| 212 | -// Constant.count = 3; | |
| 213 | -// PollingUtils.startPollingService(context, 60, CountService.class, CountService.STATUS_ACTION); | |
| 206 | + handler.post(statusRunnable); | |
| 214 | 207 | } |
| 215 | 208 | |
| 209 | + private Runnable statusRunnable = new Runnable() { | |
| 210 | + @Override | |
| 211 | + public void run() { | |
| 212 | + handler.postDelayed(this, 10 * 1000); | |
| 213 | + FangTangApplication application = (FangTangApplication) getApplication(); | |
| 214 | +// int mConnectionState = GREENBluetoothLeService.mConnectionState; | |
| 215 | + statusPromoteTv.setText(application.getServerStatus() + "\n" + application.getLightStatus()); | |
| 216 | + | |
| 217 | + } | |
| 218 | + }; | |
| 219 | + | |
| 216 | 220 | @Override |
| 217 | 221 | protected void onResume() { |
| 218 | 222 | super.onResume(); | ... | ... |
| ... | ... | @@ -11,9 +11,12 @@ import com.qnbar.smc.service.TelinkLightService; |
| 11 | 11 | import com.telink.TelinkApplication; |
| 12 | 12 | import com.telink.bluetooth.light.AdvanceStrategy; |
| 13 | 13 | import com.telink.bluetooth.light.model.Mesh; |
| 14 | +import com.xgimi.gimicinema.entity.Status; | |
| 14 | 15 | |
| 15 | 16 | public class FangTangApplication extends TelinkApplication { |
| 16 | 17 | private Mesh mesh; |
| 18 | + private Status.ConnectServerStatus serverStatus = Status.ConnectServerStatus.SERVER_IDLE; | |
| 19 | + private Status.LightStatus lightStatus = Status.LightStatus.LIGHT_IDLE; | |
| 17 | 20 | private String currentPlayUrl; |
| 18 | 21 | |
| 19 | 22 | @Override |
| ... | ... | @@ -76,6 +79,22 @@ public class FangTangApplication extends TelinkApplication { |
| 76 | 79 | this.currentPlayUrl = currentPlayUrl; |
| 77 | 80 | } |
| 78 | 81 | |
| 82 | + public void setServerStatus(Status.ConnectServerStatus lightStatus) { | |
| 83 | + this.serverStatus = lightStatus; | |
| 84 | + } | |
| 85 | + | |
| 86 | + public Status.ConnectServerStatus getServerStatus() { | |
| 87 | + return serverStatus; | |
| 88 | + } | |
| 89 | + | |
| 90 | + public Status.LightStatus getLightStatus() { | |
| 91 | + return lightStatus; | |
| 92 | + } | |
| 93 | + | |
| 94 | + public void setLightStatus(Status.LightStatus lightStatus) { | |
| 95 | + this.lightStatus = lightStatus; | |
| 96 | + } | |
| 97 | + | |
| 79 | 98 | public static void initLog(int logLever) { |
| 80 | 99 | LogUtils.Builder builder = new LogUtils.Builder() |
| 81 | 100 | .setLogSwitch(true)// 设置log总开关,包括输出到控制台和文件,默认开 | ... | ... |
| 1 | +package com.xgimi.gimicinema.entity; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Created by wugian on 2017/7/27. | |
| 5 | + */ | |
| 6 | + | |
| 7 | +public class Status { | |
| 8 | + | |
| 9 | + public enum ConnectServerStatus { | |
| 10 | + SERVER_IDLE, SERVER_CONNECTING, SERVER_CONNECTED, | |
| 11 | + } | |
| 12 | + | |
| 13 | + public enum LightStatus { | |
| 14 | + LIGHT_IDLE, LIGHT_CONNECTED | |
| 15 | + } | |
| 16 | +} | ... | ... |
| 1 | -<?xml version="1.0" encoding="utf-8"?> | |
| 2 | -<!-- | |
| 1 | +<?xml version="1.0" encoding="utf-8"?><!-- | |
| 3 | 2 | ~ Copyright (c) 2016 wugian |
| 4 | 3 | ~ Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 4 | ~ you may not use this file except in compliance with the License. |
| ... | ... | @@ -15,109 +14,120 @@ |
| 15 | 14 | --> |
| 16 | 15 | |
| 17 | 16 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 18 | - android:gravity="center|top" | |
| 19 | - android:id="@+id/background" | |
| 20 | - android:orientation="vertical" | |
| 21 | - android:background="@drawable/ic_general_bg" | |
| 22 | - android:layout_width="match_parent" | |
| 23 | - android:layout_height="match_parent"> | |
| 17 | + android:id="@+id/background" | |
| 18 | + android:layout_width="match_parent" | |
| 19 | + android:layout_height="match_parent" | |
| 20 | + android:background="@drawable/ic_general_bg" | |
| 21 | + android:gravity="center|top" | |
| 22 | + android:orientation="vertical"> | |
| 24 | 23 | |
| 25 | 24 | |
| 26 | - <ScrollView android:layout_width="match_parent" | |
| 27 | - android:layout_height="wrap_content" | |
| 28 | - android:id="@+id/scrollView" | |
| 29 | - android:scrollbars="none"> | |
| 25 | + <ScrollView | |
| 26 | + android:id="@+id/scrollView" | |
| 27 | + android:layout_width="match_parent" | |
| 28 | + android:layout_height="wrap_content" | |
| 29 | + android:scrollbars="none"> | |
| 30 | 30 | |
| 31 | - <LinearLayout android:id="@+id/main" | |
| 32 | - android:gravity="center|top" | |
| 33 | - android:orientation="vertical" | |
| 34 | - android:paddingLeft="20dp" | |
| 35 | - android:paddingRight="20dp" | |
| 36 | - android:paddingTop="40dp" | |
| 37 | - android:clipChildren="false" | |
| 38 | - android:clipToPadding="false" | |
| 39 | - android:layout_width="match_parent" | |
| 40 | - android:layout_height="wrap_content"> | |
| 31 | + <LinearLayout | |
| 32 | + android:id="@+id/main" | |
| 33 | + android:layout_width="match_parent" | |
| 34 | + android:layout_height="wrap_content" | |
| 35 | + android:clipChildren="false" | |
| 36 | + android:clipToPadding="false" | |
| 37 | + android:gravity="center|top" | |
| 38 | + android:orientation="vertical" | |
| 39 | + android:paddingLeft="20dp" | |
| 40 | + android:paddingRight="20dp" | |
| 41 | + android:paddingTop="40dp"> | |
| 41 | 42 | |
| 42 | 43 | <LinearLayout |
| 43 | - android:layout_width="match_parent" | |
| 44 | - android:layout_height="wrap_content" | |
| 45 | - android:gravity="top|left" | |
| 46 | - android:layout_marginLeft="20dp" | |
| 47 | - android:layout_marginBottom="10dp" | |
| 48 | - android:layout_marginRight="20dp" | |
| 49 | - android:orientation="horizontal"> | |
| 44 | + android:layout_width="match_parent" | |
| 45 | + android:layout_height="wrap_content" | |
| 46 | + android:layout_marginBottom="10dp" | |
| 47 | + android:layout_marginLeft="20dp" | |
| 48 | + android:layout_marginRight="20dp" | |
| 49 | + android:gravity="top|left" | |
| 50 | + android:orientation="horizontal"> | |
| 51 | + | |
| 50 | 52 | <LinearLayout |
| 51 | - android:layout_width="0dp" | |
| 52 | - android:layout_weight="1" | |
| 53 | - android:layout_height="wrap_content" | |
| 54 | - android:orientation="vertical"> | |
| 53 | + android:layout_width="0dp" | |
| 54 | + android:layout_height="wrap_content" | |
| 55 | + android:layout_weight="1" | |
| 56 | + android:orientation="vertical"> | |
| 57 | + | |
| 55 | 58 | <Button |
| 56 | - android:id="@+id/mainSearch" | |
| 57 | - android:paddingLeft="10dp" | |
| 58 | - android:onClick="openSearch" | |
| 59 | - android:drawableLeft="@drawable/ic_search_movie" | |
| 60 | - android:nextFocusLeft="@id/mainSearch" | |
| 61 | - android:nextFocusRight="@id/mainSearch" | |
| 62 | - android:nextFocusUp="@id/mainSearch" | |
| 63 | - android:drawablePadding="5dp" | |
| 64 | - android:textColor="@color/general_text_color" | |
| 65 | - android:textSize="24sp" | |
| 66 | - android:gravity="left|center" | |
| 67 | - android:layout_width="wrap_content" | |
| 68 | - android:layout_height="56dp" | |
| 69 | - android:background="@color/trans" | |
| 70 | - android:text="@string/search_movie"/> | |
| 59 | + android:id="@+id/mainSearch" | |
| 60 | + android:layout_width="wrap_content" | |
| 61 | + android:layout_height="56dp" | |
| 62 | + android:background="@color/trans" | |
| 63 | + android:drawableLeft="@drawable/ic_search_movie" | |
| 64 | + android:drawablePadding="5dp" | |
| 65 | + android:gravity="left|center" | |
| 66 | + android:nextFocusLeft="@id/mainSearch" | |
| 67 | + android:nextFocusRight="@id/mainSearch" | |
| 68 | + android:nextFocusUp="@id/mainSearch" | |
| 69 | + android:onClick="openSearch" | |
| 70 | + android:paddingLeft="10dp" | |
| 71 | + android:text="@string/search_movie" | |
| 72 | + android:textColor="@color/general_text_color" | |
| 73 | + android:textSize="24sp" /> | |
| 74 | + | |
| 71 | 75 | <ImageView |
| 72 | - android:layout_marginLeft="20dp" | |
| 73 | - android:layout_width="wrap_content" | |
| 74 | - android:layout_height="wrap_content" | |
| 75 | - android:id="@+id/movie_source_type_iv" | |
| 76 | - android:visibility="visible" | |
| 77 | - android:background="@drawable/m_baofeng"/> | |
| 76 | + android:id="@+id/movie_source_type_iv" | |
| 77 | + android:layout_width="wrap_content" | |
| 78 | + android:layout_height="wrap_content" | |
| 79 | + android:layout_marginLeft="20dp" | |
| 80 | + android:background="@drawable/m_baofeng" | |
| 81 | + android:visibility="visible" /> | |
| 78 | 82 | |
| 79 | 83 | </LinearLayout> |
| 80 | 84 | |
| 81 | - <LinearLayout android:layout_width="wrap_content" | |
| 82 | - android:layout_height="wrap_content" | |
| 83 | - android:gravity="center" | |
| 84 | - android:orientation="vertical"> | |
| 85 | + <LinearLayout | |
| 86 | + android:layout_width="wrap_content" | |
| 87 | + android:layout_height="wrap_content" | |
| 88 | + android:gravity="center" | |
| 89 | + android:orientation="vertical"> | |
| 90 | + | |
| 85 | 91 | <ImageView |
| 86 | - android:layout_width="100dp" | |
| 87 | - android:layout_height="100dp" | |
| 88 | - android:id="@+id/controlQrCode"/> | |
| 89 | - <TextView android:layout_width="150dp" | |
| 90 | - android:layout_height="wrap_content" | |
| 91 | - android:gravity="center" | |
| 92 | - android:visibility="invisible" | |
| 93 | - android:textSize="18sp" | |
| 94 | - android:textColor="@color/white" | |
| 95 | - android:text="@string/qr_promote"/> | |
| 92 | + android:id="@+id/controlQrCode" | |
| 93 | + android:layout_width="100dp" | |
| 94 | + android:layout_height="100dp" | |
| 95 | + android:visibility="gone" /> | |
| 96 | + | |
| 97 | + <TextView | |
| 98 | + android:id="@+id/statusPromote_tv" | |
| 99 | + android:layout_width="wrap_content" | |
| 100 | + android:layout_height="wrap_content" | |
| 101 | + android:gravity="center" | |
| 102 | + android:text="@string/qr_promote" | |
| 103 | + android:textColor="@color/white" | |
| 104 | + android:textSize="18sp" | |
| 105 | + android:visibility="visible" /> | |
| 96 | 106 | </LinearLayout> |
| 97 | 107 | </LinearLayout> |
| 98 | 108 | |
| 99 | 109 | |
| 100 | 110 | <com.xgimi.gimicinema.view.OrderRecyclerView |
| 101 | - android:id="@+id/recommend" | |
| 102 | - android:layout_width="wrap_content" | |
| 103 | - android:layout_height="wrap_content" | |
| 104 | - android:layout_marginTop="10dp" | |
| 105 | - android:nextFocusLeft="@+id/recommend" | |
| 106 | - android:nextFocusRight="@+id/recommend" | |
| 107 | - android:gravity="center"/> | |
| 111 | + android:id="@+id/recommend" | |
| 112 | + android:layout_width="wrap_content" | |
| 113 | + android:layout_height="wrap_content" | |
| 114 | + android:layout_marginTop="10dp" | |
| 115 | + android:gravity="center" | |
| 116 | + android:nextFocusLeft="@+id/recommend" | |
| 117 | + android:nextFocusRight="@+id/recommend" /> | |
| 108 | 118 | |
| 109 | 119 | <com.xgimi.gimicinema.view.OrderRecyclerView |
| 110 | - android:id="@+id/classification" | |
| 111 | - android:layout_width="match_parent" | |
| 112 | - android:layout_height="wrap_content" | |
| 113 | - android:layout_marginTop="20dp" | |
| 114 | - android:paddingLeft="20dp" | |
| 115 | - android:paddingRight="20dp" | |
| 116 | - android:paddingTop="20dp" | |
| 117 | - android:layout_marginBottom="20dp" | |
| 118 | - android:nextFocusLeft="@+id/classification" | |
| 119 | - android:nextFocusRight="@+id/classification" | |
| 120 | - android:gravity="center"/> | |
| 120 | + android:id="@+id/classification" | |
| 121 | + android:layout_width="match_parent" | |
| 122 | + android:layout_height="wrap_content" | |
| 123 | + android:layout_marginBottom="20dp" | |
| 124 | + android:layout_marginTop="20dp" | |
| 125 | + android:gravity="center" | |
| 126 | + android:nextFocusLeft="@+id/classification" | |
| 127 | + android:nextFocusRight="@+id/classification" | |
| 128 | + android:paddingLeft="20dp" | |
| 129 | + android:paddingRight="20dp" | |
| 130 | + android:paddingTop="20dp" /> | |
| 121 | 131 | </LinearLayout> |
| 122 | 132 | </ScrollView> |
| 123 | 133 | </LinearLayout> |
| \ No newline at end of file | ... | ... |
Please
register
or
login
to post a comment