From 12d6db5780d8a2121a3bef2d58bf897b24ff552a Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 12 六月 2024 15:54:29 +0800
Subject: [PATCH] Merge branch 'dev'

---
 app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java | 1003 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,003 insertions(+), 0 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
new file mode 100644
index 0000000..e505902
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
@@ -0,0 +1,1003 @@
+package com.hdl.photovoltaic.ui.powerstation;
+
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.content.res.AppCompatResources;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+
+import com.google.gson.Gson;
+import com.hdl.linkpm.sdk.core.exception.HDLException;
+import com.hdl.photovoltaic.R;
+import com.hdl.photovoltaic.bean.PageNumberObject;
+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.HomepageTitleTabSwitch;
+import com.hdl.photovoltaic.enums.LowerTagType;
+import com.hdl.photovoltaic.enums.PowerStationStatus;
+import com.hdl.photovoltaic.enums.ShowErrorMode;
+import com.hdl.photovoltaic.enums.SortType;
+import com.hdl.photovoltaic.enums.SortValue;
+import com.hdl.photovoltaic.listener.CloudCallBeak;
+import com.hdl.photovoltaic.listener.LinkCallBack;
+import com.hdl.photovoltaic.other.HdlCommonLogic;
+import com.hdl.photovoltaic.other.HdlDeviceLogic;
+import com.hdl.photovoltaic.other.HdlLogLogic;
+import com.hdl.photovoltaic.other.HdlResidenceLogic;
+import com.hdl.photovoltaic.other.HdlThreadLogic;
+import com.hdl.photovoltaic.other.HdlUniLogic;
+import com.hdl.photovoltaic.ui.adapter.DeviceInfoAdapter;
+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.ui.bean.StatusOverviewBean;
+import com.hdl.photovoltaic.uni.HDLUniMP;
+import com.hdl.photovoltaic.utils.PermissionUtils;
+import com.hdl.photovoltaic.utils.URLEncodingUtils;
+import com.hdl.photovoltaic.widget.DefaultFilteringDialog;
+import com.hdl.photovoltaic.widget.DelayedConfirmationCancelDialog;
+import com.hdl.sdk.link.common.exception.HDLLinkException;
+import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
+import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
+import com.hdl.sdk.link.core.config.HDLLinkConfig;
+import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient;
+import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 鐢电珯鍜岃澶�-鐣岄潰
+ */
+public class HouseAndDeviceFragment extends CustomBaseFragment {
+
+    private boolean isReadData = false;
+    private FragmentHouseListBinding viewBinding;
+    private HouseInfoAdapter houseInfoAdapter;
+
+    private DeviceInfoAdapter deviceInfoAdapter;
+
+    private List<HouseIdBean> houseListBeanIDList;
+    private List<CloudInverterDeviceBean> deviceInfoList;
+    private int currentHouseListPage = 0; // 褰撳墠鐢电珯鍒楄〃椤电爜
+    private int currentHouseListTotal = 0; // 鐢电珯鍒楄〃鎬婚〉鐮�
+    private boolean isHouseLoadingMore = false; // 鏍囪鐢电珯鍒楄〃姝e湪鍔犺浇鏇村鏁版嵁
+
+    private int currentDeviceListPage = 0; // 褰撳墠璁惧鍒楄〃椤电爜
+    private int currentDeviceListTotal = 0; // 璁惧鍒楄〃鎬婚〉鐮�
+    private boolean isDeviceLoadingMore = false; // 鏍囪璁惧鍒楄〃姝e湪鍔犺浇鏇村鏁版嵁
+
+    private boolean isClickPowerStationLabel = true;//(鐢电珯鏍囩=true锛岃澶囨爣绛�=false)
+
+    private String key = SortValue.all;
+    private String value = SortValue.all;//descending:闄嶅簭,ascending:鍗囧簭
+    private String installedCapacityMinValue = "";//鏈�灏忕粍涓插閲�(瑁呮満瀹归噺)
+    private String installedCapacityMaxValue = "";//鏈�澶х粍涓插閲�(瑁呮満瀹归噺)
+    private String gridTypeValue = "";//骞剁綉鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,FULL_GRID:骞剁綉,OFFLINE:绂荤綉)
+    private String powerStationStatusValue = PowerStationStatus.All;//鐢电珯鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,1:姝e父(杩愯),2:绂荤嚎,3:寰呮帴鍏�,4:鏁呴殰)
+
+    private final long pageSize = 20;//椤垫暟
+
+
+    @Override
+    public Object getContentView() {
+        viewBinding = FragmentHouseListBinding.inflate(getLayoutInflater());
+        return viewBinding.getRoot();
+    }
+
+    @Override
+    public void onBindView(Bundle savedInstanceState) {
+        getStatusOverview();
+        initData();
+        //鍒濆鍖�
+        initView();
+        //鍒濆鍖栫晫闈㈢洃鍚櫒
+        initEvent();
+    }
+
+    private void initEvent() {
+
+        //鐢电珯鏍囩
+        viewBinding.powerStationLabel.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (isClickPowerStationLabel) {
+                    return;
+                }
+                isClickPowerStationLabel = true;
+                selectedTitleLabelStyle();
+                getStatusOverview();
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+
+            }
+        });
+        //璁惧鏍囩
+        viewBinding.deviceLabel.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (!isClickPowerStationLabel) {
+                    return;
+                }
+                isClickPowerStationLabel = false;
+                selectedTitleLabelStyle();
+                loadNextPageDeviceList(true, 1, true);
+            }
+        });
+        //鍏ㄩ儴
+        viewBinding.powerStationAllIl.parentLl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                powerStationStatusValue = PowerStationStatus.All;
+                selectedStationStateStyle(viewBinding.powerStationAllIl.parentLl, viewBinding.powerStationAllIl.stationTotalTv, viewBinding.powerStationAllIl.stationTitleTv, true);
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+            }
+        });
+        //鏁呴殰
+        viewBinding.powerStationFaultsIl.parentLl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                powerStationStatusValue = PowerStationStatus.malfunction;
+                selectedStationStateStyle(viewBinding.powerStationFaultsIl.parentLl, viewBinding.powerStationFaultsIl.stationTotalTv, viewBinding.powerStationFaultsIl.stationTitleTv, true);
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+            }
+        });
+        //绂荤嚎
+        viewBinding.powerStationOfflineIl.parentLl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                powerStationStatusValue = PowerStationStatus.off;
+                selectedStationStateStyle(viewBinding.powerStationOfflineIl.parentLl, viewBinding.powerStationOfflineIl.stationTotalTv, viewBinding.powerStationOfflineIl.stationTitleTv, true);
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+            }
+        });
+        //寰呮帴鍏�
+        viewBinding.powerStationConnectedIl.parentLl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                powerStationStatusValue = PowerStationStatus.connecting;
+                selectedStationStateStyle(viewBinding.powerStationConnectedIl.parentLl, viewBinding.powerStationConnectedIl.stationTotalTv, viewBinding.powerStationConnectedIl.stationTitleTv, true);
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+            }
+        });
+
+        //鐢电珯娣诲姞
+        viewBinding.addIv.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+
+            }
+        });
+        //鐢电珯鎼滅储
+        viewBinding.powerStationSearchClickCl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Intent intent = new Intent();
+                intent.setClass(_mActivity, HouseSearchActivity.class);
+                startActivity(intent);
+            }
+        });
+        //榛樿閫夋嫨鍙傛暟鍥炬爣
+        viewBinding.powerStationDefaultConditionIv.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                DefaultFilteringDialog defaultFilteringDialog = new DefaultFilteringDialog(_mActivity);
+                defaultFilteringDialog.show();
+                defaultFilteringDialog.initState(installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue);
+                defaultFilteringDialog.setOnClickListener(new DefaultFilteringDialog.OnClickListener() {
+                    @Override
+                    public void confirm(String min, String max, String state) {
+                        installedCapacityMinValue = min;//鏈�灏忕粍涓插閲�(瑁呮満瀹归噺)
+                        installedCapacityMaxValue = max;//鏈�澶х粍涓插閲�(瑁呮満瀹归噺)
+                        gridTypeValue = state;//骞剁綉鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,FULL_GRID:骞剁綉,OFFLINE:绂荤綉)
+                        loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                    }
+                });
+            }
+        });
+
+        //鐢电珯璁剧疆涓嬫媺绠ご棰滆壊
+        viewBinding.fragmentHouseSrl.setColorSchemeResources(R.color.text_FF245EC3);
+        //鐢电珯涓嬫媺璇诲彇
+        viewBinding.fragmentHouseSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+            @Override
+            public void onRefresh() {
+                viewBinding.fragmentHouseSrl.setRefreshing(false);
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                getStatusOverview();
+            }
+        });
+        //鐢电珯涓婃媺璇诲彇
+        viewBinding.fragmentHouseSrlListRc.addOnScrollListener(new RecyclerView.OnScrollListener() {
+            @Override
+            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
+//                super.onScrolled(recyclerView, dx, dy);
+
+                LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
+                if (layoutManager == null) {
+                    return;
+                }
+                int visibleItemCount = layoutManager.getChildCount();
+                int totalItemCount = layoutManager.getItemCount();
+                int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
+                if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) {
+                    if (!isHouseLoadingMore) {
+                        // 婊戝姩鍒颁簡搴曢儴锛屾墽琛岀浉搴旂殑鎿嶄綔
+                        HdlLogLogic.print("---婊戝姩鍒颁簡搴曢儴");
+                        loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, ++currentHouseListPage, false);
+                    }
+                }
+            }
+        });
+        //鐢电珯璇︽儏杩涘叆,鍒犻櫎鐢电珯,绉诲姩鐢电珯浣嶇疆
+        houseInfoAdapter.setNoOnclickListener(new HouseInfoAdapter.OnclickListener() {
+            @Override
+            public void onClick(int position, HouseIdBean houseIdBean) {
+                //鐐瑰嚮浣忓畢璇︽儏
+                HdlLogLogic.print("鐐瑰嚮浣忓畢璇︽儏---" + new Gson().toJson(houseIdBean), false);
+                HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
+                String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS + "?homeId=" + houseIdBean.getHomeId() + "&homeName=" + houseIdBean.getHomeName() + "&powerStationStatus=" + houseIdBean.getPowerStationStatus();
+                HdlUniLogic.getInstance().openUniMP(path, null);
+
+            }
+
+            @Override
+            public void onMoveClick(int position, HouseIdBean houseIdBean) {
+                if (position == 0) {
+                    HdlThreadLogic.toast(_mActivity, getString(R.string.already_the_first_one));
+                    return;
+                }
+                String frontHomeId = "";
+                if (position > 1) {
+                    frontHomeId = houseListBeanIDList.get(position - 2).getHomeId();
+                }
+                HdlResidenceLogic.getInstance().moveResidence(houseIdBean.getHomeId(), frontHomeId, new CloudCallBeak<Boolean>() {
+                    @Override
+                    public void onSuccess(Boolean obj) {
+                        //绉诲姩鐢电珯浣嶇疆
+                        HdlResidenceLogic.getInstance().moveHouseId(houseIdBean.getHomeId());
+                        initData();//鍒濆鍖栫紦瀛樻暟鎹�
+                        houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//閲嶆柊鍒锋柊鍒楄〃
+                        nullDataUpdateUi();//妫�娴嬫暟鎹槸鍚︿负绌�
+                    }
+
+                    @Override
+                    public void onFailure(HDLException e) {
+                        HdlThreadLogic.toast(_mActivity, e);
+                    }
+                });
+
+
+            }
+
+            @Override
+            public void onDelClick(int position, HouseIdBean houseIdBean) {
+
+                DelayedConfirmationCancelDialog delayedConfirmationCancelDialog = new DelayedConfirmationCancelDialog(_mActivity);
+                delayedConfirmationCancelDialog.show();
+                delayedConfirmationCancelDialog.isHideTitle(true);
+                String homeName = "\"" + houseIdBean.getHomeName() + "\"";
+                delayedConfirmationCancelDialog.setContent(getString(R.string.delete_power_station).replace("%s", homeName));
+
+                delayedConfirmationCancelDialog.startCountdown(4);
+                delayedConfirmationCancelDialog.setYesOnclickListener(new DelayedConfirmationCancelDialog.onYesOnclickListener() {
+                    @Override
+                    public void Confirm() {
+                        delayedConfirmationCancelDialog.dismiss();
+                        showLoading(getString(R.string.deleting_please_wait));
+                        HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(houseIdBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() {
+                            @Override
+                            public void onSuccess(List<GatewayBean> list) {
+                                //鍙戣捣鍒犻櫎鐢电珯鎸囦护
+                                deleteResidence(houseIdBean.getHomeId(), list);
+
+                            }
+
+                            @Override
+                            public void onFailure(HDLException e) {
+                                //鍙戣捣鍒犻櫎鐢电珯鎸囦护
+                                deleteResidence(houseIdBean.getHomeId(), null);
+                            }
+                        });
+
+//                        //鍒犻櫎浣忓畢
+//                        HdlResidenceLogic.getInstance().delResidence(houseIdBean.getHomeId(), new CloudCallBeak<Boolean>() {
+//                            @Override
+//                            public void onSuccess(Boolean obj) {
+//                                HdlResidenceLogic.getInstance().delHouseId(houseIdBean.getHomeId());
+//                                initData();//鍒濆鍖栫紦瀛樻暟鎹�
+//                                houseInfoAdapter.setList(houseListBeanIDList);//閲嶆柊鍒锋柊鍒楄〃
+//                                nullDataUpdateUi(houseListBeanIDList);//妫�娴嬫暟鎹槸鍚︿负绌�
+//                            }
+//
+//                            @Override
+//                            public void onFailure(HDLException e) {
+//                                HdlThreadLogic.toast(_mActivity, e);
+//                            }
+//                        });
+                    }
+                });
+                delayedConfirmationCancelDialog.setNoOnclickListener(new DelayedConfirmationCancelDialog.onNoOnclickListener() {
+                    @Override
+                    public void Cancel() {
+                        delayedConfirmationCancelDialog.dismiss();
+                    }
+                });
+
+            }
+        });
+        //鐢电珯缂栬緫鎸夐挳
+        viewBinding.editIv.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                startActivity(HouseListEditActivity.class);
+            }
+        });
+        //鐢电珯鍚嶇О绛涢��
+        viewBinding.stationNameRl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                boolean isSelected = !v.isSelected();
+                viewBinding.stationNameRl.setSelected(isSelected);
+                viewBinding.stationNameIv.setSelected(isSelected);
+                key = SortType.homeNameSort;
+                value = isSelected ? SortValue.ascending : SortValue.descending;
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+            }
+        });
+        //鐢电珯鍙戠數鍔熺巼绛涢��
+        viewBinding.stationPowerRl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                boolean isSelected = !v.isSelected();
+                viewBinding.stationPowerRl.setSelected(isSelected);
+                viewBinding.stationPowerIv.setSelected(isSelected);
+                key = SortType.powerSort;
+                value = isSelected ? SortValue.ascending : SortValue.descending;
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+            }
+        });
+        //鐢电珯褰撴棩鍙戠數閲忕瓫閫�
+        viewBinding.stationDayRl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                boolean isSelected = !v.isSelected();
+                viewBinding.stationDayRl.setSelected(isSelected);
+                viewBinding.stationDayIv.setSelected(isSelected);
+                key = SortType.todayElectricitySort;
+                value = isSelected ? SortValue.ascending : SortValue.descending;
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+            }
+        });
+        //鐢电珯褰撴湀鍙戠數閲忕瓫閫�
+        viewBinding.stationMonthRl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                boolean isSelected = !v.isSelected();
+                viewBinding.stationMonthRl.setSelected(isSelected);
+                viewBinding.stationMonthIv.setSelected(isSelected);
+                key = SortType.monthElectricitySort;
+                value = isSelected ? SortValue.ascending : SortValue.descending;
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+            }
+        });
+        //璁惧鐐瑰嚮
+        deviceInfoAdapter.setOnclickListener(new DeviceInfoAdapter.OnClickListener() {
+            @Override
+            public void onClick(int position, CloudInverterDeviceBean deviceBean) {
+//                GatewayBean gatewayBean = new GatewayBean();
+//                gatewayBean.setCategorySecondName(deviceBean.getCategorySecondName());
+//                gatewayBean.setDevice_mac(deviceBean.getOsn());
+//                gatewayBean.setDevice_model(deviceBean.getOmodel());
+//                gatewayBean.setOid(deviceBean.getOid());
+//                gatewayBean.setGatewayId(deviceBean.getGatewayId());
+//                gatewayBean.setAddresses(deviceBean.getAddresses());
+//                gatewayBean.setSid(deviceBean.getSid());
+//                gatewayBean.setDeviceId(deviceBean.getDeviceId());
+//                gatewayBean.setDevice_name(deviceBean.getName());
+//                gatewayBean.setDeviceStatus(deviceBean.getDeviceStatus());
+//                gatewayBean.setHomeId(deviceBean.getHomeId());
+//                gatewayBean.setSpk(deviceBean.getSpk());
+//                gatewayBean.setDeviceType(deviceBean.getDeviceType());
+                if (deviceBean.getDeviceStatus() == 4) {
+                    HdlThreadLogic.toast(_mActivity, R.string.device_off);
+                    return;
+                }
+                //閰嶇疆鏈湴閫氫俊鐨勪俊鎭�
+                HDLLinkConfig.getInstance().setHomeId(deviceBean.getHomeId());
+                HDLLinkConfig.getInstance().setLocalSecret(deviceBean.getLocalSecret());
+                List<CloudInverterDeviceBean> newList = new ArrayList<>();
+                newList.add(deviceBean);
+                //鐩殑鏄负浜嗚幏鍙栨嬁鍒扮綉鍏矷D锛宮qtt閫氳绉橀挜绛変俊鎭紝鎷垮埌鍚庣紦瀛樺埌鏈湴閫嗗彉鍣ㄥ垪琛ㄩ噷闈紝鍙戦�佹暟鎹暟鎹椂鑷姩鍘荤紦瀛樺垪琛ㄩ噷闈㈠幓鏌ユ壘锛�
+                HdlDeviceLogic.getInstance().setDeviceRemoteInfo(newList, deviceBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() {
+                    @Override
+                    public void onSuccess(List<GatewayBean> obj) {
+                        GatewayBean newGatewayBean = HDLLinkLocalGateway.getInstance().getLocalGateway(deviceBean.getOsn());
+                        String jsonEncryption = URLEncodingUtils.encodeURIComponent(new Gson().toJson(newGatewayBean));
+                        String path = HDLUniMP.UNI_EVENT_OPEN_DEVICE_DETAILS + "?inverterInfo=" + jsonEncryption;
+                        HdlUniLogic.getInstance().openUniMP(path, null);
+                    }
+
+                    @Override
+                    public void onFailure(HDLException e) {
+
+                    }
+                });
+            }
+        });
+        //璁惧璁剧疆涓嬫媺绠ご棰滆壊
+        viewBinding.fragmentDeviceSrl.setColorSchemeResources(R.color.text_FF245EC3);
+        //璁惧涓嬫媺璇诲彇
+        viewBinding.fragmentDeviceSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+            @Override
+            public void onRefresh() {
+                viewBinding.fragmentDeviceSrl.setRefreshing(false);
+                loadNextPageDeviceList(false, 1, true);
+            }
+        });
+        //璁惧涓婃媺璇诲彇
+        viewBinding.fragmentDeviceSrlListRc.addOnScrollListener(new RecyclerView.OnScrollListener() {
+            @Override
+            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
+//                super.onScrolled(recyclerView, dx, dy);
+
+                LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
+                if (layoutManager == null) {
+                    return;
+                }
+                int visibleItemCount = layoutManager.getChildCount();
+                int totalItemCount = layoutManager.getItemCount();
+                int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
+                if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) {
+                    if (!isDeviceLoadingMore) {
+                        // 婊戝姩鍒颁簡搴曢儴锛屾墽琛岀浉搴旂殑鎿嶄綔
+                        HdlLogLogic.print("---婊戝姩鍒颁簡搴曢儴");
+                        loadNextPageDeviceList(false, ++currentDeviceListPage, false);
+                    }
+                }
+            }
+        });
+        //璁惧鎼滅储
+        viewBinding.deviceSearchCl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Intent intent = new Intent();
+                intent.setClass(_mActivity, DeviceSearchActivity.class);
+                startActivity(intent);
+            }
+        });
+
+    }
+
+    private void initView() {
+        viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);
+        viewBinding.deviceLabelParent.setVisibility(View.GONE);
+
+        viewBinding.powerStationAllIl.stationTitleTv.setText(getString(R.string.message_all));
+        viewBinding.powerStationFaultsIl.stationTitleTv.setText(getString(R.string.my_power_station_malfunction));
+        viewBinding.powerStationOfflineIl.stationTitleTv.setText(getString(R.string.my_power_station_off_line));
+        viewBinding.powerStationConnectedIl.stationTitleTv.setText(getString(R.string.to_be_added));
+
+        selectedStationStateStyle(viewBinding.powerStationAllIl.parentLl, viewBinding.powerStationAllIl.stationTotalTv, viewBinding.powerStationAllIl.stationTitleTv, true);
+        //鐢电珯鏍囩
+        houseInfoAdapter = new HouseInfoAdapter(_mActivity);
+        viewBinding.fragmentHouseSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
+        viewBinding.fragmentHouseSrlListRc.setAdapter(houseInfoAdapter);
+        houseInfoAdapter.setList(this.houseListBeanIDList, powerStationStatusValue);
+
+        //璁惧鏍囩
+        deviceInfoAdapter = new DeviceInfoAdapter(_mActivity);
+        viewBinding.fragmentDeviceSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
+        viewBinding.fragmentDeviceSrlListRc.setAdapter(deviceInfoAdapter);
+        this.nullDataUpdateUi();
+
+
+    }
+
+    /**
+     * 鐢电珯鍜岃澶囨爣绛炬牱寮�
+     */
+    private void selectedTitleLabelStyle() {
+        if (isClickPowerStationLabel) {
+            viewBinding.powerStationLabel.setTextAppearance(R.style.Text20Style);
+            viewBinding.deviceLabel.setTextAppearance(R.style.Text16Style);
+            viewBinding.editIv.setVisibility(View.VISIBLE);//缂栬緫鍥炬爣闅愯棌
+            viewBinding.addIv.setVisibility(View.VISIBLE);//娣诲姞鍥炬爣闅愯棌
+            viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);//鐢电珯鏍囩銆愮埗瀹瑰櫒銆戞樉绀�
+            viewBinding.deviceLabelParent.setVisibility(View.GONE);//璁惧鏍囩銆愮埗瀹瑰櫒銆戦殣钘�
+            if (viewBinding.deviceNullDataIc.getRoot().getVisibility() == View.VISIBLE) {
+                viewBinding.deviceNullDataIc.getRoot().setVisibility(View.GONE);
+            }
+        } else {
+            viewBinding.deviceLabel.setTextAppearance(R.style.Text20Style);
+            viewBinding.powerStationLabel.setTextAppearance(R.style.Text16Style);
+            viewBinding.editIv.setVisibility(View.GONE);//缂栬緫鍥炬爣闅愯棌
+            viewBinding.addIv.setVisibility(View.GONE);//娣诲姞鍥炬爣闅愯棌
+            viewBinding.powerStationLabelParent.setVisibility(View.GONE);//鐢电珯鏍囩銆愮埗瀹瑰櫒銆戦殣钘�
+            viewBinding.deviceLabelParent.setVisibility(View.VISIBLE);//璁惧鏍囩銆愮埗瀹瑰櫒銆戞樉绀�
+            if (viewBinding.homeNullDataIc.getRoot().getVisibility() == View.VISIBLE) {
+                viewBinding.homeNullDataIc.getRoot().setVisibility(View.GONE);
+            }
+        }
+
+    }
+
+    /**
+     * 鏄剧ず閫変腑鐘舵�佹牱寮�
+     *
+     * @param linearLayout         缁勪欢
+     * @param numberTv             缁勪欢
+     * @param titleTv              缁勪欢
+     * @param isShowSelectedStatus 鏄惁鏄剧ず鐘舵�佹牱寮�
+     */
+    private void selectedStationStateStyle(LinearLayout linearLayout, TextView numberTv, TextView titleTv, boolean isShowSelectedStatus) {
+        viewBinding.powerStationAllIl.parentLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
+        viewBinding.powerStationFaultsIl.parentLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
+        viewBinding.powerStationOfflineIl.parentLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
+        viewBinding.powerStationConnectedIl.parentLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
+
+        viewBinding.powerStationAllIl.stationTotalTv.setTextColor(getResources().getColor(R.color.text_E6000000, null));
+        viewBinding.powerStationAllIl.stationTitleTv.setTextColor(getResources().getColor(R.color.text_66000000, null));
+
+        viewBinding.powerStationFaultsIl.stationTotalTv.setTextColor(getResources().getColor(R.color.text_E6000000, null));
+        viewBinding.powerStationFaultsIl.stationTitleTv.setTextColor(getResources().getColor(R.color.text_66000000, null));
+
+        viewBinding.powerStationOfflineIl.stationTotalTv.setTextColor(getResources().getColor(R.color.text_E6000000, null));
+        viewBinding.powerStationOfflineIl.stationTitleTv.setTextColor(getResources().getColor(R.color.text_66000000, null));
+
+        viewBinding.powerStationConnectedIl.stationTotalTv.setTextColor(getResources().getColor(R.color.text_E6000000, null));
+        viewBinding.powerStationConnectedIl.stationTitleTv.setTextColor(getResources().getColor(R.color.text_66000000, null));
+
+
+        if (isShowSelectedStatus) {
+            linearLayout.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.selected_8_38c494));
+            numberTv.setTextColor(getResources().getColor(R.color.text_FFFFFFFF, null));
+            titleTv.setTextColor(getResources().getColor(R.color.text_FFFFFFFF, null));
+        }
+
+    }
+
+    private void initData() {
+        if (isClickPowerStationLabel) {
+            this.houseListBeanIDList = new ArrayList<>();
+            this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList());
+        } else {
+            this.deviceInfoList = new ArrayList<>();
+            this.deviceInfoList.addAll(HdlDeviceLogic.getInstance().getDeviceList());
+        }
+
+
+    }
+
+    /**
+     * 鏀跺埌EventBUs閫氱煡
+     *
+     * @param eventBus 鏁版嵁
+     */
+    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
+    public void onEventMessage(BaseEventBus eventBus) {
+        super.onEventMessage(eventBus);
+        if (HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL.equals(eventBus.getTopic())) {
+            if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
+                // 鍙栨秷绮樻�т簨浠�
+                EventBus.getDefault().removeStickyEvent(eventBus);
+                //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
+                loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                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())) {
+                // 鍙栨秷绮樻�т簨浠�
+                EventBus.getDefault().removeStickyEvent(eventBus);
+                //todo 鐜板湪榛樿鍒锋柊鍏ㄩ儴
+                //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())) {
+            // 鍙栨秷绮樻�т簨浠�
+            EventBus.getDefault().removeStickyEvent(eventBus);
+            //鏄湪鐢电珯鍒楄〃椤垫墠杩涙潵杩欓噷
+            if (HdlCommonLogic.lowerTagType == LowerTagType.power_station && isClickPowerStationLabel) {
+                //uin鍏抽棴浣忓畢璇︽儏鐣岄潰閫氱煡
+                if (MqttRecvClient.getInstance() != null) {
+                    MqttRecvClient.getInstance().removeAllTopic();
+                }
+                loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+            }
+        } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) {
+            // 鍙栨秷绮樻�т簨浠�
+            EventBus.getDefault().removeStickyEvent(eventBus);
+//            if (!isClickPowerStationLabel) {
+//                return;
+//            }
+            //杩涘幓浣忓畢璇︽儏uni璇诲彇閫嗗彉鍣ㄥ垪琛ㄦ垚鍔熷悗閫氱煡
+            for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(UserConfigManage.getInstance().getHomeId()).size(); i++) {
+                String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(UserConfigManage.getInstance().getHomeId()).get(i).getGatewayId();
+                //瀛楃涓叉槸鑷繁鎸夎鍒欐嫾鎺ョ殑,閲岄潰娉ㄥ唽涓婚鏃朵細瑙f瀽瀛楃涓�,鍙嬁getGatewayId()鍊�;
+                String topic = "/user/" + gatewayId + "/#";
+                //杩涘幓浣忓畢璇︽儏寮�濮嬭闃呬富棰�
+                MqttRecvClient.getInstance().checkAndsubscribeAllTopics(topic);
+            }
+        } else if (eventBus.getTopic().equals(ConstantManage.homepage_title_tab_switch)) {
+            //鎺ユ敹澶栭儴鐐瑰嚮浜嬩欢
+            if (eventBus.getType().equals(HomepageTitleTabSwitch.powerstation.toString())) {
+                // 鍙栨秷绮樻�т簨浠�
+                EventBus.getDefault().removeStickyEvent(eventBus);
+                HdlLogLogic.print("姝e湪鐐瑰嚮銆愮數绔欍��");
+                if (!isReadData) {
+                    //1锛屼粠棣栭〉-鏁呴殰-杩涙潵-鐢电珯锛堜笉璇诲彇锛�
+                    //2锛屼粠鐢电珯-杩涙潵-鐢电珯锛堣鍙栦竴娆�,鍚庨潰杩涙潵涓嶅湪璇诲彇锛�
+                    loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                    getStatusOverview();
+                }
+            } else if (eventBus.getType().equals(PowerStationStatus.All)) {
+                isClickPowerStationLabel = true;
+                selectedTitleLabelStyle();
+                viewBinding.powerStationAllIl.parentLl.performClick();
+            } else if (eventBus.getType().equals(PowerStationStatus.malfunction)) {
+                isClickPowerStationLabel = true;
+                selectedTitleLabelStyle();
+                viewBinding.powerStationFaultsIl.parentLl.performClick();
+            } else if (eventBus.getType().equals(PowerStationStatus.off)) {
+                isClickPowerStationLabel = true;
+                selectedTitleLabelStyle();
+                viewBinding.powerStationOfflineIl.parentLl.performClick();
+            } else if (eventBus.getType().equals(PowerStationStatus.connecting)) {
+                isClickPowerStationLabel = true;
+                selectedTitleLabelStyle();
+                viewBinding.powerStationConnectedIl.parentLl.performClick();
+            } else if (eventBus.getType().equals(ConstantManage.station_edit)) {
+                //缂栬緫鍚庢洿鏂颁竴涓嬩綇瀹呭垪琛�
+                //loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+//                getStatusOverview();
+                if (houseInfoAdapter != null) {
+                    initData();
+                    //鏇存柊UI
+                    houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);
+                }
+            }
+        }
+    }
+
+
+    /**
+     * 鐢电珯鐘舵�佹瑙�
+     */
+    private void getStatusOverview() {
+        HdlResidenceLogic.getInstance().getStatusOverview(new CloudCallBeak<StatusOverviewBean>() {
+            @Override
+            public void onSuccess(StatusOverviewBean statusOverviewBean) {
+                if (statusOverviewBean == null) {
+                    return;
+                }
+                viewBinding.powerStationAllIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getTotal()));
+                viewBinding.powerStationFaultsIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getFault()));
+                viewBinding.powerStationOfflineIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getOffline()));
+                viewBinding.powerStationConnectedIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getConnecting()));
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+
+            }
+        });
+    }
+
+
+    /**
+     * 鍒锋柊UI锛堢數绔欙級
+     *
+     * @param isRefreshing         琛ㄧず鏄笅鎷夊埛鏂扮殑
+     * @param key                  鍙戠數鍔熺巼鎺掑簭(powerSort);
+     *                             浠婃棩鍙戠數閲忔帓搴�(todayElectricitySort);
+     *                             鍒涘缓鏃堕棿鎺掑簭(createTimeSort);
+     * @param keyValue             (descending:闄嶅簭
+     *                             ascending:鍗囧簭),
+     * @param installedCapacityMin 鏈�灏忕粍涓插閲�(瑁呮満瀹归噺)
+     * @param installedCapacityMax 鏈�澶х粍涓插閲�(瑁呮満瀹归噺)
+     * @param gridType             骞剁綉鐘舵�� (鍏ㄩ儴 锛�"";FULL_GRID 锛� 骞剁綉;OFFLINE 锛氱缃�)
+     * @param powerStationStatus   鐢电珯鐘舵�� (鍏ㄩ儴  锛�"";1 锛� 姝e父;2 锛� 绂荤嚎; 3 锛� 寰呮帴鍏�;4 锛� 鏁呴殰)
+     * @param pageNo               椤电爜
+     * @param isClear              鏄惁娓呴櫎鏁版嵁
+     */
+    private void loadNextPageHouseList(boolean isRefreshing, String key, String keyValue, String installedCapacityMin, String installedCapacityMax, String gridType, String powerStationStatus, long pageNo, boolean isClear) {
+        isReadData = true;
+        if (isClear) {
+            clearData();
+        }
+        //绗竴椤佃鍙栨暟鎹己鍒惰鍙�
+        if (pageNo > 1 && currentHouseListPage > currentHouseListTotal) {
+            --currentHouseListPage;
+            //褰撳墠椤典笉鑳藉ぇ浜庢�婚〉鏁�
+            return;
+        }
+        isHouseLoadingMore = true;//鏍囪璇诲彇鐘舵��
+        if (isRefreshing) {
+            showLoading(getString(R.string.device_loading));
+        }
+
+        //鑾峰彇浣忓畢(鐢电珯)ID鍒楄〃
+        HdlResidenceLogic.getInstance().getResidenceIdList(key, keyValue, installedCapacityMin, installedCapacityMax, gridType, powerStationStatus, pageNo, pageSize, new CloudCallBeak<HdlResidenceLogic.HouseBeanClass>() {
+            @Override
+            public void onSuccess(HdlResidenceLogic.HouseBeanClass houseBeanClass) {
+                HdlThreadLogic.runMainThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (isRefreshing) {
+                            hideLoading();
+                        }
+                        isHouseLoadingMore = false;
+                        if (houseBeanClass != null) {
+                            currentHouseListTotal = (int) houseBeanClass.getTotalPage();
+                            currentHouseListPage = (int) houseBeanClass.getPageNo();
+                            //鏇存柊缂撳瓨
+                            HdlResidenceLogic.getInstance().setHouseIdList(houseBeanClass.getList());
+                            if (houseInfoAdapter != null) {
+                                initData();
+                                //鏇存柊UI
+                                houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);
+                            }
+                        }
+                        nullDataUpdateUi();
+                    }
+                }, _mActivity, ShowErrorMode.YES);
+
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+                HdlThreadLogic.runMainThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (currentHouseListPage > 1) {
+                            --currentHouseListPage;
+                        }
+                        isHouseLoadingMore = false;
+                        if (isRefreshing) {
+                            hideLoading();
+                        }
+
+                    }
+                }, _mActivity, ShowErrorMode.YES);
+            }
+        });
+    }
+
+    /**
+     * 鍒锋柊UI锛堣澶囷級
+     *
+     * @param isRefreshing 琛ㄧず鏄笅鎷夊埛鏂扮殑
+     * @param pageNo       椤电爜
+     * @param isClear      true琛ㄧず娓呯┖缂撳瓨
+     */
+    private void loadNextPageDeviceList(boolean isRefreshing, long pageNo, boolean isClear) {
+        if (isClear) {
+            clearData();
+        }
+        //绗竴椤佃鍙栨暟鎹己鍒惰鍙�
+        if (pageNo > 1 && currentDeviceListPage > currentDeviceListTotal) {
+            --currentDeviceListPage;
+            //褰撳墠椤典笉鑳藉ぇ浜庢�婚〉鏁�
+            return;
+        }
+        isDeviceLoadingMore = true;//鏍囪璇诲彇鐘舵��
+        if (isRefreshing) {
+            showLoading(getString(R.string.device_loading));
+        }
+        //鑾峰彇浣忓畢(鐢电珯)ID鍒楄〃
+        HdlDeviceLogic.getInstance().getPowerStationDeviceList("", pageNo, pageSize, new CloudCallBeak<PageNumberObject<CloudInverterDeviceBean>>() {
+            @Override
+            public void onSuccess(PageNumberObject<CloudInverterDeviceBean> pageNumberObject) {
+                HdlThreadLogic.runMainThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (isRefreshing) {
+                            hideLoading();
+                        }
+                        isDeviceLoadingMore = false;
+                        if (pageNumberObject != null) {
+                            currentDeviceListTotal = (int) pageNumberObject.getTotalPage();
+                            currentDeviceListPage = (int) pageNumberObject.getPageNo();
+                            //鏇存柊缂撳瓨
+                            HdlDeviceLogic.getInstance().setListDevice(pageNumberObject.getList());
+                            //鏇存柊缂撳瓨
+                            if (deviceInfoAdapter != null) {
+                                initData();
+                                //鏇存柊UI
+                                deviceInfoAdapter.setList(deviceInfoList);
+                            }
+                        }
+                        nullDataUpdateUi();
+                    }
+                }, _mActivity, ShowErrorMode.YES);
+
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+                HdlThreadLogic.runMainThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (currentDeviceListPage > 1) {
+                            --currentDeviceListPage;
+                        }
+                        isDeviceLoadingMore = false;
+                        if (isRefreshing) {
+                            hideLoading();
+                        }
+                    }
+                }, _mActivity, ShowErrorMode.YES);
+            }
+        });
+    }
+
+
+    /**
+     * 娓呯┖缂撳瓨鏁版嵁
+     */
+    private void clearData() {
+        if (isClickPowerStationLabel) {
+            currentHouseListPage = 0;// 閲嶇疆褰撳墠鐢电珯鍒楄〃椤电爜
+            currentHouseListTotal = 0;// 閲嶇疆褰撳墠鐢电珯鍒楄〃鎬婚〉鐮�
+            if (houseListBeanIDList != null) {
+                houseListBeanIDList.clear(); //娓呯┖涓存椂缂撳瓨鍒楄〃
+            }
+            HdlResidenceLogic.getInstance().clearHouseList(); //琛ㄧず寮哄埗娓呯┖鎵�鏈夌紦瀛樹俊鎭�
+        } else {
+            currentDeviceListPage = 0; // 閲嶇疆褰撳墠璁惧鍒楄〃椤电爜
+            currentDeviceListTotal = 0; // 閲嶇疆璁惧鍒楄〃鎬婚〉鐮�
+            if (deviceInfoList != null) {
+                deviceInfoList.clear();//娓呯┖涓存椂缂撳瓨鍒楄〃
+            }
+            HdlDeviceLogic.getInstance().clearDeviceList(); //琛ㄧず寮哄埗娓呯┖鎵�鏈夌紦瀛樹俊鎭�
+        }
+    }
+
+
+    /**
+     * 娌℃湁鐢电珯鍒楄〃鐨勬牱寮�
+     */
+    private void nullDataUpdateUi() {
+        boolean is_data;
+        String tipText = "";
+        if (isClickPowerStationLabel) {
+            is_data = houseListBeanIDList != null && houseListBeanIDList.size() > 0;
+            tipText = getString(R.string.my_power_station_data_null);
+            HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.homeNullDataIc.getRoot(), viewBinding.homeNullDataIc.nullDataGifAnimationIv, viewBinding.homeNullDataIc.nullDataTv, tipText, is_data);
+
+        } else {
+            is_data = deviceInfoList != null && deviceInfoList.size() > 0;
+            tipText = getString(R.string.no_equipment);
+
+            HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.deviceNullDataIc.getRoot(), viewBinding.deviceNullDataIc.nullDataGifAnimationIv, viewBinding.deviceNullDataIc.nullDataTv, tipText, is_data);
+
+        }
+    }
+
+    /**
+     * 鍒犻櫎鐢电珯,閫嗗彉鍣�
+     * (寮�濮嬪垹闄ょ數绔欙紝鍚屾椂锛屽悜閫嗗彉鍣ㄥ彂閫佸垵濮嬪寲閫嗗彉鍣ㄦ寚浠�,鏃犻』澶勭悊缁撴灉)
+     *
+     * @param list 璁惧鍒楄〃
+     */
+    private void initializeInverter(List<GatewayBean> list) {
+        if (list == null || list.size() == 0) {
+            return;
+        }
+        for (int i = 0; i < list.size(); i++) {
+            GatewayBean gatewayBean = list.get(i);
+            HdlDeviceLogic.getInstance().initializeInverter(gatewayBean.getDevice_mac(), new LinkCallBack<Boolean>() {
+                @Override
+                public void onSuccess(Boolean obj) {
+//                                HdlLogLogic.print("鍒濆鍖栭�嗗彉鍣ㄦ垚鍔�-->mac:" + cloudInverterDeviceBean.getOsn(),true);
+                }
+
+                @Override
+                public void onError(HDLLinkException e) {
+//                                HdlLogLogic.print("鍒濆鍖栭�嗗彉鍣ㄥけ璐�-->mac:" + cloudInverterDeviceBean.getOsn(),true);
+                }
+            });
+        }
+    }
+
+    /**
+     * 鍒犻櫎鐢电珯
+     *
+     * @param homeId 鐢电珯id
+     * @param list   閫嗗彉鍣ㄥ垪琛�
+     */
+    private void deleteResidence(String homeId, List<GatewayBean> list) {
+
+        //鍒犻櫎浣忓畢
+        HdlResidenceLogic.getInstance().delResidence(homeId, new CloudCallBeak<Boolean>() {
+            @Override
+            public void onSuccess(Boolean obj) {
+                hideLoading();
+                initializeInverter(list); //鍙戣捣鍒濆鍖栨寚浠ょ粰閫嗗彉鍣�;锛堟敞鎰�:鍙兘鏄湰鍦板彂閫佷簡(瑕佹悳绱㈠眬鍩熺綉閫嗗彉鍣ㄥ垪琛紝寤虹珛鏈湴閫氳閫氶亾),鍒犻櫎鐢电珯鎴愬姛鍚�,浜戠瑙g粦閫嗗彉鍣ㄧ殑鍏崇郴锛�
+                HdlResidenceLogic.getInstance().delHouseId(homeId);//鍒犻櫎鐢电珯缂撳瓨
+                initData();//鍒濆鍖栫紦瀛樻暟鎹�
+                houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//閲嶆柊鍒锋柊鍒楄〃
+                getStatusOverview();//鍒犻櫎鎴愬姛鍚庡埛鏂扮數绔欑姸鎬佹瑙�
+                nullDataUpdateUi();//妫�娴嬫暟鎹槸鍚︿负绌�
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+                hideLoading();
+                HdlThreadLogic.toast(_mActivity, e);
+            }
+        });
+    }
+
+
+    @Override
+    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+        if (requestCode == PermissionUtils.STATUS_SUCCESS) {
+            for (int i = 0; i < permissions.length; i++) {
+                if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
+                    if (mPermissionsResultCallback != null) {
+                        mPermissionsResultCallback.succeed();
+                    }
+                } else {
+                    if (mPermissionsResultCallback != null) {
+                        mPermissionsResultCallback.failing();
+                    }
+                }
+
+            }
+        }
+
+    }
+
+
+    private PermissionsResultCallback mPermissionsResultCallback;
+
+    public interface PermissionsResultCallback {
+
+        void succeed();
+
+        void failing();
+
+    }
+
+
+}

--
Gitblit v1.8.0