From 7be166b93cafc5ba0c5cdb8ede2e4f664136e9ee Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期二, 05 一月 2021 15:41:05 +0800
Subject: [PATCH] 2021-01-05 1.增加000E读备注回复协议

---
 app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 106 insertions(+), 3 deletions(-)

diff --git a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java
index 6c3e53b..5b9f4e9 100644
--- a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java
+++ b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java
@@ -19,11 +19,17 @@
 import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo;
 import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.DevicesData;
 import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager;
+import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLSDK;
+import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HandleSearch;
 import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.BgmInfoEvent;
 import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DevicesInfoEvent;
 import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.ThirdPartyBgmInfoEvent;
 import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.WarningInfoEvent;
+import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil;
+import com.hdl.sdk.hdl_core.Util.TransformUtil.HDLUtlis;
 import com.hdl.sdk.hdl_sdk.R;
+import com.hdl.sdk.hdl_sdk.utlis.HDLLog;
 
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
@@ -37,7 +43,8 @@
 public class MainActivity extends AppCompatActivity {
 
     private Button btn, btn2;
-    private Button btn_get_all,btn_on_all, btn_off_all;
+    private Button btn_get_all,btn_on_all, btn_off_all,btn_getlocal,btn_getlocal_add;
+    private Button btn_setting;
     private TextView tv;
     private EditText editText;
     private List<DevicesData> devicesDatas;
@@ -51,7 +58,18 @@
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
-        HDLCommand.init(this);
+        NetWorkUtil.setIsGetWifiBroadCast(true);
+        HDLSDK.init(this);
+        //鎺у埗BUS璁惧妯″紡
+        HDLSDK.startHomeMode(this);
+
+//        //鎺у埗RCU璁惧妯″紡
+//        HDLSDK.startRcuMode(this,"192.168.10.111");
+
+//
+//        HDLCommand.init(this);
+//        HDLCommand.startHomeMode(this);
+
 //        /**閰嶇疆鏄惁寮�鍚疭DK鎵撳嵃鏃ュ織锛岄粯璁や负鎵撳紑*/
 //        HDLCommand.setHDLLogOpen(false);//
 
@@ -62,7 +80,12 @@
         initView();
         setOnClick();
 
+//        String str = "#Z018TYPE0010,music121";
+//        String result = str.substring(4, 5);
+//        HDLLog.I("result:"+result);
+
 //        hideTestButton();
+
     }
 
     private void initView() {
@@ -72,7 +95,11 @@
         btn_get_all = findViewById(R.id.btn_get_all);
         btn_on_all = findViewById(R.id.btn_on_all);
         btn_off_all = findViewById(R.id.btn_off_all);
-        
+        btn_getlocal = findViewById(R.id.btn_getlocal);
+
+        btn_getlocal_add = findViewById(R.id.btn_getlocal_add);
+
+        btn_setting  = findViewById(R.id.btn_setting);
         tv = findViewById(R.id.tv);
         editText = findViewById(R.id.edt);
         editText.setText("172.168.188.100");
@@ -142,8 +169,84 @@
                 sendAll(false);
             }
         });
+
+
+        btn_getlocal.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+
+                clearListView();
+                getLocalDevicesDataList();
+            }
+        });
+
+
+
+
+        btn_getlocal_add.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                startActivity(AddDevicesActivity.class);
+
+            }
+        });
+
+        btn_setting.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                startActivity(SettingActivity.class);
+            }
+        });
     }
 
+    public void startActivity(Class<?> clazz) {
+        Intent intent = new Intent(this, clazz);
+        startActivity(intent);
+    }
+    /**
+     * 璇诲彇鍜屽姞杞芥湰鍦版暟鎹�
+     */
+    private void getLocalDevicesDataList() {
+        devicesDatas = HDLDeviceManager.getLocalDevicesDataList();
+        if (devicesDatas.size() > 0) {
+            updateDeviceListView();
+            HandleSearch.refreshAllDevicesStateAndRemarks();//濡傛灉鏈湴鏈夋暟鎹紝鍙互璋冪敤璇ユ柟娉曪紝閬嶅巻鍙戦�佹寚浠わ紝鍒锋柊鎵�鏈夎澶囩殑澶囨敞鍜岀姸鎬�
+        } else {
+            showToast("鏈湴鏁版嵁涓虹┖");
+        }
+    }
+
+    /**
+     * 鍒锋柊璁惧鍒楄〃鏁版嵁
+     */
+    private void updateDeviceListView() {
+        int countAll = 0;
+        for (DevicesData devicesData : devicesDatas) {
+            countAll += devicesData.getAppliancesInfoList().size();
+        }
+        tv.setText("鎬诲叡妯″潡鏁帮細" + devicesDatas.size() + " 鎬诲叡鍥炶矾鏁帮細" + countAll);
+        HDLLog.I("鑾峰彇鏁版嵁鎴愬姛锛氭�诲叡妯″潡鏁帮細" + devicesDatas.size() + " 鎬诲叡鍥炶矾鏁帮細" + countAll);
+
+        for (int i = 0; i < devicesDatas.size(); i++) {
+            if (TextUtils.isEmpty(devicesDatas.get(i).getRemark())) {
+                listString.add("鏆傛棤澶囨敞");
+            } else {
+                listString.add(devicesDatas.get(i).getRemark());
+            }
+        }
+        adapter.notifyDataSetChanged();
+    }
+
+
+    /**
+     * 娓呯┖鏁版嵁骞跺埛鏂板垪琛�
+     */
+    private void clearListView() {
+        if (devicesDatas != null) devicesDatas.clear();
+        if (listString != null) listString.clear();
+
+        adapter.notifyDataSetChanged();
+    }
 
     @Override
     protected void onDestroy() {

--
Gitblit v1.8.0