From b9cc7390e8e8ce64c41c26fb369c98ce669d660c Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 07 五月 2025 15:02:30 +0800
Subject: [PATCH] Merge branch '1.2.0'

---
 app/src/main/java/com/hdl/photovoltaic/ui/test/TestMainActivity.java |  534 ++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 385 insertions(+), 149 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/test/TestMainActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/test/TestMainActivity.java
index 00fc088..38d67d1 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/test/TestMainActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/test/TestMainActivity.java
@@ -2,30 +2,39 @@
 
 import androidx.recyclerview.widget.LinearLayoutManager;
 
-import android.content.Context;
 import android.os.Bundle;
 import android.text.TextUtils;
-import android.util.Log;
 import android.view.View;
+import android.widget.Toast;
+
 
 import com.google.gson.Gson;
 import com.hdl.linkpm.sdk.core.exception.HDLException;
 import com.hdl.photovoltaic.R;
 import com.hdl.photovoltaic.base.CustomBaseActivity;
+import com.hdl.photovoltaic.bean.InverterBean;
+import com.hdl.photovoltaic.bean.PageNumberObject;
 import com.hdl.photovoltaic.config.UserConfigManage;
 import com.hdl.photovoltaic.databinding.ActivityTestMainBinding;
 import com.hdl.photovoltaic.enums.ShowErrorMode;
+import com.hdl.photovoltaic.internet.TcpClient;
 import com.hdl.photovoltaic.listener.CloudCallBeak;
 import com.hdl.photovoltaic.listener.LinkCallBack;
 import com.hdl.photovoltaic.other.HdlDeviceLogic;
+import com.hdl.photovoltaic.other.HdlResidenceLogic;
 import com.hdl.photovoltaic.other.HdlThreadLogic;
 import com.hdl.photovoltaic.ui.bean.CloudInverterChildDeviceBean;
+import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean;
+import com.hdl.photovoltaic.ui.bean.HouseIdBean;
 import com.hdl.photovoltaic.ui.bean.OidBean;
+import com.hdl.photovoltaic.ui.test.adapters.HomeAdapter;
+import com.hdl.photovoltaic.ui.test.dialogs.DialogDeviceList;
+import com.hdl.photovoltaic.ui.test.dialogs.DialogHomeList;
 import com.hdl.photovoltaic.widget.ConfirmationCancelDialog;
-import com.hdl.photovoltaic.widget.ConfirmationExceptionDialog;
 import com.hdl.sdk.link.common.exception.HDLLinkException;
 import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
 import com.hdl.sdk.link.core.callback.GatewayCallBack;
+import com.hdl.sdk.link.core.callback.ModbusCallBack;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -38,7 +47,14 @@
     private ActivityTestMainBinding viewBinding;
     private TestTitleAdapter testTitleAdapter;
 
+    private List<HouseIdBean> mHouseIdBeanList = new ArrayList<>();
     private List<OidBean> mOidList;
+
+    private GatewayBean mGatewayBean;
+    private String s = "";
+
+    private String mHomeId;
+    private String mHomeName;
 
     @Override
     public Object getContentView() {
@@ -55,43 +71,37 @@
         viewBinding.listItemRl.setAdapter(testTitleAdapter);
         initView();
         initEvent();
+        readData();
 
+    }
+
+    private void readData() {
+        loadNextPageHouseList(true);
     }
 
     /**
      * 鍒濆鍖�
      */
     private void initView() {
-
-        String homeId = "娴嬭瘯浣忓畢ID=" + UserConfigManage.getInstance().getHomeId();
-        String homeName = "娴嬭瘯浣忓畢鍚嶇О=" + UserConfigManage.getInstance().getHomeName();
+        this.mHomeId = UserConfigManage.getInstance().getHomeId();
+        this.mHomeName = UserConfigManage.getInstance().getHomeName();
+        String homeId = "娴嬭瘯鐢电珯Id=" + this.mHomeId;
+        String homeName = "娴嬭瘯鐢电珯鍚嶇О=" + this.mHomeName;
         viewBinding.homeIdTv.setText(homeId);
         viewBinding.homeNameTv.setText(homeName);
-
 
     }
 
     private void initEvent() {
-        viewBinding.topBackBtn.setOnClickListener(this);
+        viewBinding.topBackLl.setOnClickListener(this);
         viewBinding.topLogBtn.setOnClickListener(this);
+        viewBinding.clickCommandTv.setOnClickListener(this);
+        viewBinding.clickSelectHomeTv.setOnClickListener(this);
+        viewBinding.clickSelectDeviceTv.setOnClickListener(this);
         testTitleAdapter.setItemOnClickListener(new TestTitleAdapter.OnClickListener() {
             @Override
             public void OnClick(int position, String title) {
-
-
-                if (TextUtils.isEmpty(UserConfigManage.getInstance().getHomeId())) {
-                    // TODO: 10/30/23 璇峰厛閫夋嫨浣忓畢杩涜娴嬭瘯,鍚﹀垯鏃犳硶杩涜閫嗗彉鍣ㄦ寚浠ゆ祴璇�;
-                    TipDialog("璇峰厛閫夋嫨浣忓畢杩涜娴嬭瘯,鍚﹀垯鏃犳硶杩涜閫嗗彉鍣ㄦ寚浠ゆ祴璇�.", null);
-                    return;
-                }
-                GatewayBean gatewayBean = HdlDeviceLogic.getInstance().getCurrentHomeMainGateway();
-                if (gatewayBean == null && !title.equals("鎼滅储閫嗗彉鍣ㄥ垪琛�(0)") && !title.equals("鎼滅储銆愪綇瀹呫�戦�嗗彉鍣ㄥ垪琛�(1)")) {
-                    // TODO: 10/30/23 鎵句笉鍒颁綇瀹呯殑涓婚�嗗彉鍣�,璇峰厛纭鏄惁缁戝畾閫嗗彉鍣紝鍐嶈繘琛岄�嗗彉鍣ㄦ寚浠ゆ祴璇�;
-                    TipDialog("鎵句笉鍒颁綇瀹呯殑銆愪富閫嗗彉鍣ㄣ��,璇峰厛纭鏄惁缁戝畾杩囬�嗗彉鍣紝鍐嶈繘琛岄�嗗彉鍣ㄦ寚浠ゆ祴璇�.", null);
-                    return;
-                }
-                showLoading();
-                startRequest(position, gatewayBean);
+                startRequest(position, mGatewayBean);
             }
         });
     }
@@ -100,10 +110,18 @@
     @Override
     public void onClick(View v) {
         int id = v.getId();
-        if (id == viewBinding.topBackBtn.getId()) {
+        if (id == viewBinding.topBackLl.getId()) {
             finish();
         } else if (id == viewBinding.topLogBtn.getId()) {
             startActivity(TestLogActivity.class);
+
+        } else if (id == viewBinding.clickCommandTv.getId()) {
+
+        } else if (id == viewBinding.clickSelectHomeTv.getId()) {
+            selectHome();
+
+        } else if (id == viewBinding.clickSelectDeviceTv.getId()) {
+            selectDevice();
 
         }
     }
@@ -115,13 +133,15 @@
      */
     private List<String> getTitleList() {
         List<String> s = new ArrayList<>();
-        s.add("鎼滅储閫嗗彉鍣ㄥ垪琛�(0)");
+        s.add("鎼滅储銆愭墍鏈夈�戦�嗗彉鍣ㄥ垪琛�(0)");
         s.add("鎼滅储銆愪綇瀹呫�戦�嗗彉鍣ㄥ垪琛�(1)");
         s.add("鑾峰彇閫嗗彉鍣╫id鍒楄〃(2)");
         s.add("璇诲彇閫嗗彉鍣ㄨ鎯�(3)");
-        s.add("娓呴櫎閫嗗彉鍣ㄤ綇瀹匢d(4)");
+        s.add("瑙g粦閫嗗彉鍣�(4)");
         s.add("涓婁紶oid鍒楄〃缁欎簯绔�(5)");
         s.add("鑾峰彇閫嗗彉鍣ㄤ笅鎸傝澶囧垪琛�(6)");
+        s.add("鑾峰彇閫嗗彉鍣ㄧ殑淇℃伅(7)");
+        s.add("鎭㈠鍑哄巶璁剧疆(8)");
         return s;
     }
 
@@ -131,135 +151,258 @@
      * @param position 绱㈠紩鍊�
      */
     private void startRequest(int position, GatewayBean gatewayBean) {
-        String title = getTitleList().get(position);
-        switch (title) {
-            case "鎼滅储閫嗗彉鍣ㄥ垪琛�(0)": {
-                HdlDeviceLogic.getInstance().searchAllGateway(new GatewayCallBack() {
-                    @Override
-                    public void onSuccess(List<GatewayBean> gatewayBeanList) {
-                        List<GatewayBean> newGatewayBeanList = new ArrayList<>();
-                        for (int i = 0; i < gatewayBeanList.size(); i++) {
-                            if (HdlDeviceLogic.getInstance().isGatewaySpk(gatewayBeanList.get(i).getGatewayType())) {
-                                newGatewayBeanList.add(gatewayBeanList.get(i));
+        try {
+            String title = getTitleList().get(position);
+            switch (title) {
+                case "鎼滅储銆愭墍鏈夈�戦�嗗彉鍣ㄥ垪琛�(0)": {
+                    showLoading();
+
+                    HdlDeviceLogic.getInstance().searchAllNetworkGateway(new GatewayCallBack() {
+                        @Override
+                        public void onSuccess(List<GatewayBean> gatewayBeanList) {
+                            List<GatewayBean> newGatewayBeanList = new ArrayList<>();
+                            for (int i = 0; i < gatewayBeanList.size(); i++) {
+                                if (HdlDeviceLogic.getInstance().isGatewaySpk(gatewayBeanList.get(i).getGatewayType())) {
+                                    newGatewayBeanList.add(gatewayBeanList.get(i));
+                                }
                             }
+                            gsonConvertJsonStr(newGatewayBeanList);
                         }
-                        gsonConvertJsonStr(newGatewayBeanList);
-                    }
 
-                    @Override
-                    public void onError(HDLLinkException e) {
-                        setError(e.getMsg(), e.getCode());
-                    }
-                });
-            }
-            break;
-            case "鎼滅储銆愪綇瀹呫�戦�嗗彉鍣ㄥ垪琛�(1)": {
-                HdlDeviceLogic.getInstance().searchCurrentHomeGateway(new GatewayCallBack() {
-                    @Override
-                    public void onSuccess(List<GatewayBean> gatewayBeanList) {
-                        gsonConvertJsonStr(gatewayBeanList);
-                    }
-
-                    @Override
-                    public void onError(HDLLinkException e) {
-                        setError(e.getMsg(), e.getCode());
-                    }
-                });
-            }
-            break;
-
-            case "鑾峰彇閫嗗彉鍣╫id鍒楄〃(2)": {
-                HdlDeviceLogic.getInstance().getInverterOidList(gatewayBean.getDevice_mac(), new LinkCallBack<List<OidBean>>() {
-                    @Override
-                    public void onSuccess(List<OidBean> obj) {
-                        mOidList = obj;
-                        gsonConvertJsonStr(obj);
-                    }
-
-                    @Override
-                    public void onError(HDLLinkException e) {
-                        setError(e.getMsg(), e.getCode());
-                    }
-                });
-            }
-            break;
-
-            case "璇诲彇閫嗗彉鍣ㄨ鎯�(3)": {
-                HdlDeviceLogic.getInstance().getGatewayInfo(gatewayBean.getDevice_mac(), new LinkCallBack<GatewayBean>() {
-                    @Override
-                    public void onSuccess(GatewayBean obj) {
-                        gsonConvertJsonStr(obj);
-                    }
-
-                    @Override
-                    public void onError(HDLLinkException e) {
-                        setError(e.getMsg(), e.getCode());
-                    }
-                });
-            }
-            break;
-            case "娓呴櫎閫嗗彉鍣ㄤ綇瀹匢d(4)": {
-                TipDialog("涓�鏃︽竻闄ゆ帀閫嗗彉鍣ㄤ綇瀹卛d,閫嗗彉鍣ㄩ渶瑕侀噸鏂扮粦瀹氫綇瀹咃紝鍚﹀垯鏃犳硶娴嬭瘯閫嗗彉鍣ㄦ寚浠�;", new Listener() {
-                    @Override
-                    public void Confirmation() {
-                        HdlDeviceLogic.getInstance().clearInverterHomeId(gatewayBean.getDevice_mac(), new LinkCallBack<Boolean>() {
-                            @Override
-                            public void onSuccess(Boolean obj) {
-                                gsonConvertJsonStr(obj);
-                            }
-
-                            @Override
-                            public void onError(HDLLinkException e) {
-                                setError(e.getMsg(), e.getCode());
-                            }
-                        });
-                    }
-                });
-            }
-            break;
-            case "涓婁紶oid鍒楄〃缁欎簯绔�(5)": {
-                if (this.mOidList == null || this.mOidList.size() == 0) {
-                    hideLoading();
-                    HdlThreadLogic.toast(this, "娌℃湁oid鍒楄〃鏁版嵁锛岃鍏堣幏鍙栭�嗗彉鍣╫id鍒楄〃鏁版嵁锛屽啀閲嶆柊涓婁紶.");
-                    return;
+                        @Override
+                        public void onError(HDLLinkException e) {
+                            setError(e.getMsg(), e.getCode());
+                        }
+                    });
                 }
-                HdlDeviceLogic.getInstance().fullUpdateOid(UserConfigManage.getInstance().getHomeId(), this.mOidList, new CloudCallBeak<Boolean>() {
-                    @Override
-                    public void onSuccess(Boolean obj) {
-                        gsonConvertJsonStr(obj);
-                    }
-
-                    @Override
-                    public void onFailure(HDLException e) {
-                        setError(e.getMsg(), e.getCode());
-                    }
-                });
-            }
-            break;
-            case "鑾峰彇閫嗗彉鍣ㄤ笅鎸傝澶囧垪琛�(6)": {
-                HdlDeviceLogic.getInstance().getInverterDeviceChildDeviceList(gatewayBean.getOid(), new CloudCallBeak<List<CloudInverterChildDeviceBean>>() {
-                    @Override
-                    public void onSuccess(List<CloudInverterChildDeviceBean> obj) {
-                        gsonConvertJsonStr(obj);
-                    }
-
-                    @Override
-                    public void onFailure(HDLException e) {
-                        setError(e.getMsg(), e.getCode());
-                    }
-                });
-            }
-            break;
-            default: {
-                HdlThreadLogic.runMainThread(new Runnable() {
-                    @Override
-                    public void run() {
-                        hideLoading();
-                    }
-                }, this, ShowErrorMode.YES);
                 break;
-            }
+                case "鎼滅储銆愪綇瀹呫�戦�嗗彉鍣ㄥ垪琛�(1)": {
+                    if (TextUtils.isEmpty(this.mHomeId)) {
+                        // TODO: 10/30/23 璇峰厛閫夋嫨浣忓畢杩涜娴嬭瘯,鍚﹀垯鏃犳硶杩涜閫嗗彉鍣ㄦ寚浠ゆ祴璇�;
+                        TipDialog("璇烽�夋嫨涓�涓�愮數绔欍�戣繘琛屾祴璇�,鍚﹀垯鏃犳硶杩涜鎸囦护娴嬭瘯.", null);
+                        return;
+                    }
+                    showLoading();
+                    List<GatewayBean> gatewayBeanList = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(this.mHomeId, null);
+                    gsonConvertJsonStr(gatewayBeanList);
+                }
+                break;
 
+                case "鑾峰彇閫嗗彉鍣╫id鍒楄〃(2)": {
+                    if (mGatewayBean == null) {
+                        TipDialog("璇峰湪璁惧鍒楄〃閲岄潰閫夋嫨涓�涓�愰�嗗彉鍣ㄣ�戯紝鍐嶈繘琛屾寚浠ゆ祴璇�.", null);
+                        return;
+                    }
+                    showLoading();
+                    HdlDeviceLogic.getInstance().getInverterOidList(gatewayBean.getDevice_mac(), new LinkCallBack<List<OidBean>>() {
+                        @Override
+                        public void onSuccess(List<OidBean> obj) {
+                            mOidList = obj;
+                            gsonConvertJsonStr(obj);
+                        }
+
+                        @Override
+                        public void onError(HDLLinkException e) {
+                            setError(e.getMsg(), e.getCode());
+                        }
+                    });
+                }
+                break;
+
+                case "璇诲彇閫嗗彉鍣ㄨ鎯�(3)": {
+                    if (mGatewayBean == null) {
+                        TipDialog("璇峰湪璁惧鍒楄〃閲岄潰閫夋嫨涓�涓�愰�嗗彉鍣ㄣ�戯紝鍐嶈繘琛屾寚浠ゆ祴璇�.", null);
+                        return;
+                    }
+                    showLoading();
+                    HdlDeviceLogic.getInstance().getGatewayInfo(gatewayBean.getDevice_mac(), new LinkCallBack<InverterBean>() {
+                        @Override
+                        public void onSuccess(InverterBean obj) {
+                            gsonConvertJsonStr(obj);
+                        }
+
+                        @Override
+                        public void onError(HDLLinkException e) {
+                            setError(e.getMsg(), e.getCode());
+                        }
+                    });
+                }
+                break;
+                case "瑙g粦閫嗗彉鍣�(4)": {
+                    if (TextUtils.isEmpty(this.mHomeId)) {
+                        // TODO: 10/30/23 璇峰厛閫夋嫨浣忓畢杩涜娴嬭瘯,鍚﹀垯鏃犳硶杩涜閫嗗彉鍣ㄦ寚浠ゆ祴璇�;
+                        TipDialog("璇峰湪鐢电珯鍒楄〃閲岄潰閫夋嫨涓�涓�愮數绔欍�戣繘琛屾祴璇�,鍚﹀垯鏃犳硶杩涜鎸囦护娴嬭瘯.", null);
+                        return;
+                    }
+                    if (mGatewayBean == null) {
+                        TipDialog("璇峰湪璁惧鍒楄〃閲岄潰閫夋嫨涓�涓�愰�嗗彉鍣ㄣ�戯紝鍐嶈繘琛屾寚浠ゆ祴璇�.", null);
+                        return;
+                    }
+
+                    TipDialog("涓�鏃︽竻闄ゆ帀閫嗗彉鍣ㄤ綇瀹卛d,閫嗗彉鍣ㄩ渶瑕侀噸鏂扮粦瀹氫綇瀹咃紝鍚﹀垯鏃犳硶娴嬭瘯鎸囦护;", new Listener() {
+                        @Override
+                        public void Confirmation() {
+                            showLoading();
+                            HdlDeviceLogic.getInstance().clearInverterHomeId(gatewayBean.getDevice_mac(), new LinkCallBack<Boolean>() {
+                                @Override
+                                public void onSuccess(Boolean obj) {
+                                    s += "瑙g粦銆愭湰鍦般�戞垚鍔�--->";
+                                    HdlDeviceLogic.getInstance().delInverterDevice(mHomeId, gatewayBean.getDeviceId(), new CloudCallBeak<Boolean>() {
+                                        @Override
+                                        public void onSuccess(Boolean obj) {
+                                            s += "瑙g粦銆愪簯绔�戞垚鍔�";
+                                            gsonConvertJsonStr(s);
+                                        }
+
+                                        @Override
+                                        public void onFailure(HDLException e) {
+                                            setError(e.getMsg(), e.getCode());
+                                        }
+                                    });
+                                }
+
+                                @Override
+                                public void onError(HDLLinkException e) {
+                                    setError(e.getMsg(), e.getCode());
+                                }
+                            });
+                        }
+                    });
+                }
+                break;
+                case "涓婁紶oid鍒楄〃缁欎簯绔�(5)": {
+                    if (TextUtils.isEmpty(this.mHomeId)) {
+                        // TODO: 10/30/23 璇峰厛閫夋嫨浣忓畢杩涜娴嬭瘯,鍚﹀垯鏃犳硶杩涜閫嗗彉鍣ㄦ寚浠ゆ祴璇�;
+                        TipDialog("璇烽�夋嫨涓�涓�愮數绔欍�戣繘琛屾祴璇�,鍚﹀垯鏃犳硶杩涜鎸囦护娴嬭瘯.", null);
+                        return;
+                    }
+                    if (mGatewayBean == null) {
+                        TipDialog("璇峰湪璁惧鍒楄〃閲岄潰閫夋嫨涓�涓�愰�嗗彉鍣ㄣ�戯紝鍐嶈繘琛屾寚浠ゆ祴璇�.", null);
+                        return;
+                    }
+                    if (this.mOidList == null || this.mOidList.size() == 0) {
+                        hideLoading();
+                        HdlThreadLogic.toast(this, "娌℃湁oid鍒楄〃鏁版嵁锛岃鍏堣幏鍙栭�嗗彉鍣╫id鍒楄〃鏁版嵁锛屽啀閲嶆柊涓婁紶.");
+                        return;
+                    }
+                    showLoading();
+                    HdlDeviceLogic.getInstance().fullUpdateOid(this.mHomeId, this.mOidList, new CloudCallBeak<Boolean>() {
+                        @Override
+                        public void onSuccess(Boolean obj) {
+                            gsonConvertJsonStr(obj);
+                        }
+
+                        @Override
+                        public void onFailure(HDLException e) {
+                            setError(e.getMsg(), e.getCode());
+                        }
+                    });
+                }
+                break;
+                case "鑾峰彇閫嗗彉鍣ㄤ笅鎸傝澶囧垪琛�(6)": {
+                    if (TextUtils.isEmpty(this.mHomeId)) {
+                        // TODO: 10/30/23 璇峰厛閫夋嫨浣忓畢杩涜娴嬭瘯,鍚﹀垯鏃犳硶杩涜閫嗗彉鍣ㄦ寚浠ゆ祴璇�;
+                        TipDialog("璇烽�夋嫨涓�涓�愮數绔欍�戣繘琛屾祴璇�,鍚﹀垯鏃犳硶杩涜鎸囦护娴嬭瘯.", null);
+                        return;
+                    }
+                    if (mGatewayBean == null) {
+                        TipDialog("璇峰湪璁惧鍒楄〃閲岄潰閫夋嫨涓�涓�愰�嗗彉鍣ㄣ�戯紝鍐嶈繘琛屾寚浠ゆ祴璇�.", null);
+                        return;
+                    }
+                    showLoading();
+                    HdlDeviceLogic.getInstance().getInverterDeviceChildDeviceList(this.mHomeId, gatewayBean.getOid(), new CloudCallBeak<List<CloudInverterChildDeviceBean>>() {
+                        @Override
+                        public void onSuccess(List<CloudInverterChildDeviceBean> obj) {
+                            gsonConvertJsonStr(obj);
+                        }
+
+                        @Override
+                        public void onFailure(HDLException e) {
+                            setError(e.getMsg(), e.getCode());
+                        }
+                    });
+                }
+                break;
+                case "鑾峰彇閫嗗彉鍣ㄧ殑淇℃伅(7)": {
+                    if (mGatewayBean == null) {
+                        TipDialog("璇峰湪璁惧鍒楄〃閲岄潰閫夋嫨涓�涓�愰�嗗彉鍣ㄣ�戯紝鍐嶈繘琛屾寚浠ゆ祴璇�.", null);
+                        return;
+                    }
+                    if (TextUtils.isEmpty(mGatewayBean.getAddresses())) {
+                        TipDialog("閫嗗彉鍣╝ddresses鍦板潃涓簄ull.", null);
+                        return;
+                    }
+                    showLoading();
+                    TcpClient.getInstance().sendModBusDataToLinkGateway(gatewayBean.getDevice_mac(), mGatewayBean.getAddresses(), TcpClient.FunctionCode.ReadMultipleRegisters, 550, "8", new ModbusCallBack() {
+                        @Override
+                        public void onSuccess(int[] data) {
+                            gsonConvertJsonStr(data);
+                        }
+
+                        @Override
+                        public void onError(HDLLinkException e) {
+                            setError(e.getMsg(), e.getCode());
+                        }
+                    });
+                }
+                break;
+                case "鎭㈠鍑哄巶璁剧疆(8)": {
+                    if (mGatewayBean == null) {
+                        TipDialog("璇峰湪璁惧鍒楄〃閲岄潰閫夋嫨涓�涓�愰�嗗彉鍣ㄣ�戯紝鍐嶈繘琛屾寚浠ゆ祴璇�.", null);
+                        return;
+                    }
+                    ConfirmationCancelDialog confirmationCancelDialog = new ConfirmationCancelDialog(_mActivity);
+                    confirmationCancelDialog.show();
+                    confirmationCancelDialog.setTitle("鎻愮ず!");
+                    confirmationCancelDialog.setContent("鏄惁瑕佽В缁慭"" + mGatewayBean.getDevice_name() + "\"?");
+                    confirmationCancelDialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() {
+                        @Override
+                        public void Confirm() {
+                            confirmationCancelDialog.dismiss();
+                            showLoading("瑙g粦涓�...");
+                            HdlDeviceLogic.getInstance().initializeInverter(gatewayBean.getDevice_mac(), new LinkCallBack<Boolean>() {
+                                @Override
+                                public void onSuccess(Boolean obj) {
+                                    hideLoading();
+                                    gsonConvertJsonStr(obj);
+                                    if (!TextUtils.isEmpty(mHomeId)) {
+                                        HdlDeviceLogic.getInstance().removeLocalCacheMemoryGatewayToMac(mHomeId, mGatewayBean.getDevice_mac());
+                                        HdlDeviceLogic.getInstance().delInverterDevice(mHomeId, mGatewayBean.getDeviceId(), null);
+                                    } else {
+                                        Toast.makeText(_mActivity, "鐢电珯ID涓簄ull,瑙g粦浜戠涓婇�嗗彉鍣ㄥけ璐�", Toast.LENGTH_SHORT).show();
+                                    }
+                                }
+
+                                @Override
+                                public void onError(HDLLinkException e) {
+                                    hideLoading();
+                                    setError(e.getMsg(), e.getCode());
+                                }
+                            });
+                        }
+                    });
+                    confirmationCancelDialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() {
+                        @Override
+                        public void Cancel() {
+                            hideLoading();
+                            confirmationCancelDialog.dismiss();
+                        }
+                    });
+
+                }
+                break;
+                default: {
+                    HdlThreadLogic.runMainThread(new Runnable() {
+                        @Override
+                        public void run() {
+                            hideLoading();
+                        }
+                    }, this, ShowErrorMode.YES);
+                    break;
+                }
+
+            }
+        } catch (Exception e) {
         }
 
     }
@@ -291,6 +434,48 @@
         }, this, ShowErrorMode.YES);
     }
 
+    /**
+     * 鍒锋柊UI锛堢數绔欙級
+     *
+     * @param isRefreshing 琛ㄧず鏄笅鎷夊埛鏂扮殑
+     */
+    private void loadNextPageHouseList(boolean isRefreshing) {
+
+        if (isRefreshing) {
+            showLoading(getString(R.string.device_loading));
+        }
+        //鑾峰彇浣忓畢(鐢电珯)ID鍒楄〃
+        HdlResidenceLogic.getInstance().getResidenceIdList("", "", "", "", "", "", 1, 200, new CloudCallBeak<HdlResidenceLogic.HouseBeanClass>() {
+            @Override
+            public void onSuccess(HdlResidenceLogic.HouseBeanClass houseBeanClass) {
+                HdlThreadLogic.runMainThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (isRefreshing) {
+                            hideLoading();
+                        }
+                        mHouseIdBeanList.clear();
+                        //鏇存柊缂撳瓨
+                        mHouseIdBeanList.addAll(houseBeanClass.getList());
+                    }
+                }, _mActivity, ShowErrorMode.NO);
+
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+                HdlThreadLogic.runMainThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (isRefreshing) {
+                            hideLoading();
+                        }
+
+                    }
+                }, _mActivity, ShowErrorMode.NO);
+            }
+        });
+    }
 
     /**
      * @param s 閿欒淇℃伅
@@ -323,6 +508,57 @@
         });
     }
 
+    /**
+     * 閫夋嫨閫嗗彉鍣ㄨ皟璇�
+     */
+    public void selectDevice() {
+        List<GatewayBean> list = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(this.mHomeId, null);
+        DialogDeviceList dialogDeviceList = new DialogDeviceList(_mActivity, list);
+        dialogDeviceList.show();
+        dialogDeviceList.DeviceOnclickListener(new DialogDeviceList.OnclickListener() {
+            @Override
+            public void onClick(int position, GatewayBean gatewayBean) {
+                dialogDeviceList.dismiss();
+                if (gatewayBean == null) {
+                    return;
+                }
+                mGatewayBean = gatewayBean;
+                String str = "閫嗗彉鍣ㄥ悕绉�=" + gatewayBean.getDevice_name() + "_" + gatewayBean.getDevice_mac();
+                viewBinding.deviceNameTv.setText(str);
+
+            }
+        });
+
+    }
+
+    /**
+     * 閫夋嫨鐢电珯璋冭瘯
+     */
+    public void selectHome() {
+//        List<HouseIdBean> list = HdlResidenceLogic.getInstance().getHouseIdList();
+        List<HouseIdBean> list = this.mHouseIdBeanList;
+        DialogHomeList dialogHomeList = new DialogHomeList(_mActivity, list);
+        dialogHomeList.show();
+        dialogHomeList.DeviceOnclickListener(new HomeAdapter.OnclickListener() {
+            @Override
+            public void onClick(int position, HouseIdBean houseIdBean) {
+                dialogHomeList.dismiss();
+                if (houseIdBean == null) {
+                    return;
+                }
+                String homeId = "鐢电珯Id=" + houseIdBean.getHomeId();
+                String homeName = "鐢电珯鍚嶇О=" + houseIdBean.getHomeName();
+                viewBinding.homeIdTv.setText(homeId);
+                viewBinding.homeNameTv.setText(homeName);
+                mGatewayBean = null;
+                String str = "閫嗗彉鍣ㄥ悕绉�=null";
+                viewBinding.deviceNameTv.setText(str);
+
+            }
+        });
+
+    }
+
     public interface Listener {
         void Confirmation();
     }

--
Gitblit v1.8.0