From a8e0bddc9903d854808e9526600128e95560faa3 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期一, 30 十月 2023 18:21:25 +0800
Subject: [PATCH] 2023年10月30日18:21:12

---
 app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java |   40 +++++++++++++++++++++++++++-------------
 1 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
index 779e64f..15c910f 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
@@ -5,7 +5,6 @@
 import android.content.pm.PackageManager;
 import android.hardware.camera2.CameraManager;
 import android.os.Bundle;
-import android.util.Log;
 import android.view.View;
 
 import androidx.annotation.NonNull;
@@ -13,12 +12,9 @@
 import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
 
 import com.google.gson.Gson;
-import com.google.gson.JsonObject;
 import com.hdl.linkpm.sdk.core.exception.HDLException;
 import com.hdl.photovoltaic.R;
 import com.hdl.photovoltaic.bean.BaseEventBus;
-import com.hdl.photovoltaic.config.ConstantManage;
-import com.hdl.photovoltaic.config.UserConfigManage;
 import com.hdl.photovoltaic.databinding.FragmentHouseListBinding;
 import com.hdl.photovoltaic.base.CustomBaseFragment;
 import com.hdl.photovoltaic.enums.ShowErrorMode;
@@ -29,16 +25,16 @@
 import com.hdl.photovoltaic.other.HdlThreadLogic;
 import com.hdl.photovoltaic.other.HdlUniLogic;
 import com.hdl.photovoltaic.ui.adapter.HouseInfoAdapter;
-import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean;
 import com.hdl.photovoltaic.ui.bean.HouseIdBean;
 import com.hdl.photovoltaic.uni.HDLUniMP;
 import com.hdl.photovoltaic.utils.PermissionUtils;
+import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient;
 
 import java.util.ArrayList;
 import java.util.List;
 
 /**
- * 鐢电珯鍒楄〃鐣岄潰
+ * (浣忓畢)鐢电珯鍒楄〃-鐣岄潰
  */
 public class HouseListFragment extends CustomBaseFragment {
 
@@ -66,7 +62,6 @@
     @Override
     public void onBindView(Bundle savedInstanceState) {
         manager = (CameraManager) _mActivity.getSystemService(Context.CAMERA_SERVICE);
-
         initData();
         //鍒濆鍖�
         initView();
@@ -104,7 +99,7 @@
             @Override
             public void onRefresh() {
                 updateUIData(true);
-                Log.d("HouseListFragment", "涓嬫媺鍒锋柊");
+                HdlLogLogic.print("HouseListFragment", "涓嬫媺鍒锋柊");
             }
         });
         houseInfoAdapter.setNoOnclickListener(new HouseInfoAdapter.OnclickListener() {
@@ -113,18 +108,18 @@
                 //鐐瑰嚮浣忓畢璇︽儏
                 HdlLogLogic.print("鐐瑰嚮浣忓畢璇︽儏===" + new Gson().toJson(houseIdBean));
                 HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
-                String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS + "?homeId=" + houseIdBean.getHomeId();
+                String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS + "?homeId=" + houseIdBean.getHomeId()+"&homeName="+houseIdBean.getHomeName();
                 HdlUniLogic.getInstance().openUniMP(path, null);
             }
         });
     }
 
     private void initView() {
-        viewBinding.toolbarTopFragmentHouseListRl.topTitleTv.setText(R.string.my_power_station_鎴戠殑鐢电珯);
+        viewBinding.toolbarTopFragmentHouseListRl.topTitleTv.setText(R.string.my_power_station);
         viewBinding.toolbarTopFragmentHouseListRl.topMoreIv.setVisibility(View.VISIBLE);
         viewBinding.toolbarTopFragmentHouseListRl.topMoreIv.setImageResource(R.drawable.add);
         LinearLayoutManager linearLayout = new LinearLayoutManager(_mActivity);
-        houseInfoAdapter = new HouseInfoAdapter(this.houseListBeanIDList);
+        houseInfoAdapter = new HouseInfoAdapter(this.houseListBeanIDList,_mActivity);
         viewBinding.fragmentHouseSrlListRc.setLayoutManager(linearLayout);
         viewBinding.fragmentHouseSrlListRc.setAdapter(houseInfoAdapter);
 
@@ -141,11 +136,16 @@
         this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList());
     }
 
+    /**
+     * 鏀跺埌EventBUs閫氱煡
+     *
+     * @param eventBus 鏁版嵁
+     */
     @Override
     public void onEventMessage(BaseEventBus eventBus) {
         super.onEventMessage(eventBus);
-        //鏀跺埌EventBUs閫氱煡
-        if (ConstantManage.EVENTBUS_POST_HOME_CREATED.equals(eventBus.getType())) {
+        if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
+            //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
             updateUIData(false);
             if (eventBus.getData() != null) {
                 Gson gson = new Gson();
@@ -153,6 +153,20 @@
                 HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class);
                 HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
             }
+        } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE.equals(eventBus.getType())) {
+            //uin鍏抽棴浣忓畢璇︽儏鐣岄潰閫氱煡
+            if (MqttRecvClient.getInstance() != null) {
+                MqttRecvClient.getInstance().removeAllTopic();
+            }
+        } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) {
+            //杩涘幓浣忓畢璇︽儏uni璇诲彇閫嗗彉鍣ㄥ垪琛ㄦ垚鍔熷悗閫氱煡
+            for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().size(); i++) {
+                //String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().get(i).getGatewayId();
+                //瀛楃涓叉槸鑷繁鎸夎鍒欐嫾鎺ョ殑,閲岄潰娉ㄥ唽涓婚鏃朵細瑙f瀽瀛楃涓�,鍙嬁getGatewayId()鍊�;
+                //String topic = "/user/" + gatewayId+"/1";
+                //杩涘幓浣忓畢璇︽儏寮�濮嬭闃呬富棰�
+                MqttRecvClient.getInstance().checkAndsubscribeAllTopics("");
+            }
         }
     }
 

--
Gitblit v1.8.0