From c48f6e1e7f7fc4ca3db8ecadf441d6da942ceb8f Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期五, 22 十二月 2023 18:05:13 +0800
Subject: [PATCH] 2023年12月22日18:05:07

---
 app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java |   48 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 35 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 5d5a91a..2d5e97f 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
@@ -6,6 +6,7 @@
 import android.content.pm.PackageManager;
 import android.hardware.camera2.CameraManager;
 import android.os.Bundle;
+import android.text.TextUtils;
 import android.view.View;
 
 import androidx.annotation.NonNull;
@@ -143,11 +144,6 @@
 
     private void initData() {
         this.houseListBeanIDList = new ArrayList<>();
-//        for (int i = 0; i < 11; i++) {
-//            HouseListBean houseListBean = new HouseListBean();
-//            houseListBean.setHomeName("鐢电珯" + i);
-//            this.houseListBeanList.add(houseListBean);
-//        }
         this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList());
     }
 
@@ -159,14 +155,40 @@
     @Override
     public void onEventMessage(BaseEventBus eventBus) {
         super.onEventMessage(eventBus);
-        if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
-            //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
-            updateUIData(false);
-            if (eventBus.getData() != null) {
-                Gson gson = new Gson();
-                String json = eventBus.getData().toString();
-                HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class);
-                HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
+        if (HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL.equals(eventBus.getTopic())) {
+            if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
+                //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
+                updateUIData(false);
+                if (eventBus.getData() != null) {
+                    Gson gson = new Gson();
+                    String json = eventBus.getData().toString();
+                    HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class);
+                    HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
+
+                }
+            } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT.equals(eventBus.getType())) {
+                //uin缂栬緫浣忓畢閫氱煡
+                String homeId = HdlUniLogic.getInstance().getKeyValue("homeId", eventBus.getData());
+                String home_name = HdlUniLogic.getInstance().getKeyValue("powerStationName", eventBus.getData());
+                if (TextUtils.isEmpty(homeId) || TextUtils.isEmpty(home_name)) {
+                    return;
+                }
+                int index = -1;
+                for (int i = 0; i < houseListBeanIDList.size(); i++) {
+                    HouseIdBean houseIdBean = houseListBeanIDList.get(i);
+                    if (houseIdBean.getHomeId().equals(homeId)) {
+                        index = i;
+                        houseIdBean.setHomeName(home_name);
+                        break;
+                    }
+                }
+                if (index > -1) {
+                    if (houseInfoAdapter != null) {
+                        //鏇存柊鍗曚釜鏁版嵁
+                        houseInfoAdapter.notifyItemChanged(index);
+                    }
+                }
+
 
             }
         } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE.equals(eventBus.getType())) {

--
Gitblit v1.8.0