From b75795836a851a13e54cc4efb597262fb448217c Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 08 五月 2024 15:22:01 +0800
Subject: [PATCH] 2024年05月08日15:21:54

---
 app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java |  432 +++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 331 insertions(+), 101 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 ae48a10..0c4b333 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
@@ -1,25 +1,27 @@
 package com.hdl.photovoltaic.ui.powerstation;
 
-import android.Manifest;
-import android.content.Context;
+import android.content.Intent;
 import android.content.pm.PackageManager;
-import android.hardware.camera2.CameraManager;
 import android.os.Bundle;
 import android.view.View;
 
 import androidx.annotation.NonNull;
 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.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;
@@ -28,7 +30,9 @@
 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.DeviceBean;
 import com.hdl.photovoltaic.ui.bean.HouseIdBean;
 import com.hdl.photovoltaic.uni.HDLUniMP;
 import com.hdl.photovoltaic.utils.PermissionUtils;
@@ -42,14 +46,42 @@
 import java.util.List;
 
 /**
- * (浣忓畢)鐢电珯鍒楄〃-鐣岄潰
+ * 鐢电珯鍜岃澶�-鐣岄潰
  */
 public class HouseListFragment extends CustomBaseFragment {
     private FragmentHouseListBinding viewBinding;
     private HouseInfoAdapter houseInfoAdapter;
-    private CameraManager manager;
 
-    private List<HouseIdBean> houseListBeanIDList = null;
+    private DeviceInfoAdapter deviceInfoAdapter;
+
+    private List<HouseIdBean> houseListBeanIDList;
+    private List<DeviceBean> 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 installedCapacityMinKey = SortType.installedCapacityMin;
+    private int installedCapacityMinValue;//鏈�灏忕粍涓插閲�(瑁呮満瀹归噺)
+    private String installedCapacityMaxKey = SortType.installedCapacityMax;
+    private int installedCapacityMaxValue;//鏈�澶х粍涓插閲�(瑁呮満瀹归噺)
+    private String gridTypeKey = SortType.gridType;
+    private String gridTypeValue;//骞剁綉鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,FULL_GRID:骞剁綉,OFFLINE:绂荤綉)
+    private String powerStationStatusKey = SortType.powerStationStatus;
+    private int powerStationStatusValue;//鐢电珯鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,1:姝e父(杩愯),2:绂荤嚎,3:寰呮帴鍏�,4:鏁呴殰)
+
+    private final long pageSize = 20;//椤垫暟
 
 
     @Override
@@ -60,7 +92,6 @@
 
     @Override
     public void onBindView(Bundle savedInstanceState) {
-        manager = (CameraManager) _mActivity.getSystemService(Context.CAMERA_SERVICE);
         initData();
         //鍒濆鍖�
         initView();
@@ -74,28 +105,36 @@
         viewBinding.powerStationLabel.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                if (isClickPowerStationLabel) {
+                    return;
+                }
+                isClickPowerStationLabel = true;
                 viewBinding.powerStationLabel.setTextAppearance(R.style.Text20Style);
                 viewBinding.deviceLabel.setTextAppearance(R.style.Text16Style);
                 viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);
                 viewBinding.deviceLabelParent.setVisibility(View.GONE);//璁惧鏍囩闅愯棌
+                loadNextPageHouseList(true, 1, true);
             }
         });
         //璁惧鏍囩
         viewBinding.deviceLabel.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                if (!isClickPowerStationLabel) {
+                    return;
+                }
+                isClickPowerStationLabel = false;
                 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);
-
-
+                loadNextPageDeviceList(true, 1, true);
             }
         });
 
-        //娣诲姞鐢电珯
+        //鐢电珯娣诲姞
         viewBinding.addIv.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -103,15 +142,48 @@
 
             }
         });
-        //璁剧疆涓嬫媺绠ご棰滆壊
+        //鐢电珯娣绘悳绱�
+        viewBinding.powerStationSearchClickCl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Intent intent = new Intent();
+                intent.setClass(_mActivity, HouseSearchActivity.class);
+                startActivity(intent);
+            }
+        });
+        //鐢电珯璁剧疆涓嬫媺绠ご棰滆壊
         viewBinding.fragmentHouseSrl.setColorSchemeResources(R.color.text_FF245EC3);
+        //鐢电珯涓嬫媺璇诲彇
         viewBinding.fragmentHouseSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
             @Override
             public void onRefresh() {
-                downReadData(true);
+                viewBinding.fragmentHouseSrl.setRefreshing(false);
+                loadNextPageHouseList(true, 1, true);
             }
         });
-        //杩涘叆鐢电珯璇︽儏,鍒犻櫎鐢电珯,绉诲姩鐢电珯浣嶇疆
+        //鐢电珯涓婃媺璇诲彇
+        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, ++currentHouseListPage, false);
+                    }
+                }
+            }
+        });
+        //鐢电珯璇︽儏杩涘叆,鍒犻櫎鐢电珯,绉诲姩鐢电珯浣嶇疆
         houseInfoAdapter.setNoOnclickListener(new HouseInfoAdapter.OnclickListener() {
             @Override
             public void onClick(int position, HouseIdBean houseIdBean) {
@@ -140,7 +212,7 @@
                         HdlResidenceLogic.getInstance().moveHouseId(houseIdBean.getHomeId());
                         initData();//鍒濆鍖栫紦瀛樻暟鎹�
                         houseInfoAdapter.setList(houseListBeanIDList);//閲嶆柊鍒锋柊鍒楄〃
-                        nullDataUpdateUi(houseListBeanIDList);//妫�娴嬫暟鎹槸鍚︿负绌�
+                        nullDataUpdateUi();//妫�娴嬫暟鎹槸鍚︿负绌�
                     }
 
                     @Override
@@ -207,7 +279,7 @@
 
             }
         });
-        //缂栬緫鐢电珯鎸夐挳
+        //鐢电珯缂栬緫鎸夐挳
         viewBinding.editIv.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -218,40 +290,92 @@
         viewBinding.stationNameRl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                viewBinding.stationNameRl.setSelected(!v.isSelected());
-                viewBinding.stationNameIv.setSelected(viewBinding.stationNameRl.isSelected());
+                boolean isSelected = !v.isSelected();
+                viewBinding.stationNameRl.setSelected(isSelected);
+                viewBinding.stationNameIv.setSelected(isSelected);
+                key = SortType.homeNameSort;
+                value = isSelected ? SortValue.ascending : SortValue.descending;
             }
         });
-        //鐢电珯鍚嶇О绛涢��
-        viewBinding.stationNameRl.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                viewBinding.stationNameRl.setSelected(!v.isSelected());
-                viewBinding.stationNameIv.setSelected(viewBinding.stationNameRl.isSelected());
-            }
-        });
-        //鍙戠數鍔熺巼绛涢��
+        //鐢电珯鍙戠數鍔熺巼绛涢��
         viewBinding.stationPowerRl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                viewBinding.stationPowerRl.setSelected(!v.isSelected());
-                viewBinding.stationPowerIv.setSelected(viewBinding.stationPowerRl.isSelected());
+                boolean isSelected = !v.isSelected();
+                viewBinding.stationPowerRl.setSelected(isSelected);
+                viewBinding.stationPowerIv.setSelected(isSelected);
+                key = SortType.powerSort;
+                value = isSelected ? SortValue.ascending : SortValue.descending;
             }
         });
-        //褰撴棩鍙戠數閲忕瓫閫�
+        //鐢电珯褰撴棩鍙戠數閲忕瓫閫�
         viewBinding.stationDayRl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                viewBinding.stationDayRl.setSelected(!v.isSelected());
-                viewBinding.stationDayIv.setSelected(viewBinding.stationDayRl.isSelected());
+                boolean isSelected = !v.isSelected();
+                viewBinding.stationDayRl.setSelected(isSelected);
+                viewBinding.stationDayIv.setSelected(isSelected);
+                key = SortType.todayElectricitySort;
+                value = isSelected ? SortValue.ascending : SortValue.descending;
             }
         });
-        //褰撴湀鍙戠數閲忕瓫閫�
+        //鐢电珯褰撴湀鍙戠數閲忕瓫閫�
         viewBinding.stationMonthRl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                viewBinding.stationMonthRl.setSelected(!v.isSelected());
-                viewBinding.stationMonthIv.setSelected(viewBinding.stationMonthRl.isSelected());
+                boolean isSelected = !v.isSelected();
+                viewBinding.stationMonthRl.setSelected(isSelected);
+                viewBinding.stationMonthIv.setSelected(isSelected);
+                key = SortType.monthElectricitySort;
+                value = isSelected ? SortValue.ascending : SortValue.descending;
+            }
+        });
+        //璁惧鐐瑰嚮
+        deviceInfoAdapter.setOnclickListener(new DeviceInfoAdapter.OnClickListener() {
+            @Override
+            public void onClick(int position, DeviceBean deviceBean) {
+
+            }
+        });
+        //璁惧璁剧疆涓嬫媺绠ご棰滆壊
+        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);
             }
         });
 
@@ -260,20 +384,30 @@
     private void initView() {
         viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);
         viewBinding.deviceLabelParent.setVisibility(View.GONE);
-
-        LinearLayoutManager linearLayout = new LinearLayoutManager(_mActivity);
+        //鐢电珯鏍囩
         houseInfoAdapter = new HouseInfoAdapter(_mActivity);
-        viewBinding.fragmentHouseSrlListRc.setLayoutManager(linearLayout);
+        viewBinding.fragmentHouseSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
         viewBinding.fragmentHouseSrlListRc.setAdapter(houseInfoAdapter);
         houseInfoAdapter.setList(this.houseListBeanIDList);
-        this.nullDataUpdateUi(houseListBeanIDList);
+
+        //璁惧鏍囩
+        deviceInfoAdapter = new DeviceInfoAdapter(_mActivity);
+        viewBinding.fragmentDeviceSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
+        viewBinding.fragmentDeviceSrlListRc.setAdapter(deviceInfoAdapter);
+        this.nullDataUpdateUi();
 
 
     }
 
     private void initData() {
-        this.houseListBeanIDList = new ArrayList<>();
-        this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList());
+        if (isClickPowerStationLabel) {
+            this.houseListBeanIDList = new ArrayList<>();
+            this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList());
+        } else {
+            this.deviceInfoList = new ArrayList<>();
+            this.deviceInfoList.add(new DeviceBean());
+//            this.deviceInfoList.addAll(HdlDeviceLogic.getInstance().getListDevice());
+        }
     }
 
     /**
@@ -287,7 +421,7 @@
         if (HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL.equals(eventBus.getTopic())) {
             if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
                 //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
-                downReadData(false);
+                loadNextPageHouseList(false, 1, true);
                 if (eventBus.getData() != null) {
                     Gson gson = new Gson();
                     String json = eventBus.getData().toString();
@@ -326,7 +460,7 @@
             if (MqttRecvClient.getInstance() != null) {
                 MqttRecvClient.getInstance().removeAllTopic();
             }
-            downReadData(false);
+            loadNextPageHouseList(false, 1, true);
 
         } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) {
             //杩涘幓浣忓畢璇︽儏uni璇诲彇閫嗗彉鍣ㄥ垪琛ㄦ垚鍔熷悗閫氱煡
@@ -341,41 +475,55 @@
             //鎺ユ敹澶栭儴鐐瑰嚮浜嬩欢
             if (eventBus.getType().equals(HomepageTitleTabSwitch.powerstation.toString())) {
                 HdlLogLogic.print("姝e湪鐐瑰嚮銆愮數绔欍��");
-                initData();//鍒濆鍖栫紦瀛樻暟鎹�
-                houseInfoAdapter.setList(houseListBeanIDList);//閲嶆柊鍒锋柊鍒楄〃
+                loadNextPageHouseList(true, 1, true);
             }
         }
     }
 
 
     /**
-     * 鍒锋柊UI
+     * 鍒锋柊UI锛堢數绔欙級
      *
      * @param isRefreshing 琛ㄧず鏄笅鎷夊埛鏂扮殑
      */
-    private void downReadData(boolean isRefreshing) {
+    private void loadNextPageHouseList(boolean isRefreshing, long pageNo, boolean isClear) {
+        if (isClear) {
+            clearData();
+        }
+        //绗竴椤佃鍙栨暟鎹己鍒惰鍙�
+        if (pageNo > 1 && currentHouseListPage > currentHouseListTotal) {
+            --currentHouseListPage;
+            //褰撳墠椤典笉鑳藉ぇ浜庢�婚〉鏁�
+            return;
+        }
+        isHouseLoadingMore = true;//鏍囪璇诲彇鐘舵��
+        if (isRefreshing) {
+            showLoading();
+        }
+
         //鑾峰彇浣忓畢(鐢电珯)ID鍒楄〃
-        HdlResidenceLogic.getInstance().getResidenceIdList("", "", new CloudCallBeak<List<HouseIdBean>>() {
+        HdlResidenceLogic.getInstance().getResidenceIdList(key, value, pageNo, pageSize, new CloudCallBeak<HdlResidenceLogic.HouseBeanClass>() {
             @Override
-            public void onSuccess(List<HouseIdBean> list) {
+            public void onSuccess(HdlResidenceLogic.HouseBeanClass houseBeanClass) {
                 HdlThreadLogic.runMainThread(new Runnable() {
                     @Override
                     public void run() {
                         if (isRefreshing) {
-                            //鍏抽棴涓嬫媺鍒锋柊鐨勫湀鍦�
-                            viewBinding.fragmentHouseSrl.setRefreshing(false);
+                            hideLoading();
                         }
-                        if (list != null && list.size() > 0) {
+                        isHouseLoadingMore = false;
+                        if (houseBeanClass != null) {
+                            currentHouseListTotal = (int) houseBeanClass.getTotalPage();
+                            currentHouseListPage = (int) houseBeanClass.getPageNo();
                             //鏇存柊缂撳瓨
-                            HdlResidenceLogic.getInstance().setHouseIdList(list);
+                            HdlResidenceLogic.getInstance().setHouseIdList(houseBeanClass.getList());
                             if (houseInfoAdapter != null) {
                                 initData();
                                 //鏇存柊UI
                                 houseInfoAdapter.setList(houseListBeanIDList);
                             }
-
                         }
-                        nullDataUpdateUi(list);
+                        nullDataUpdateUi();
                     }
                 }, _mActivity, ShowErrorMode.YES);
 
@@ -386,9 +534,81 @@
                 HdlThreadLogic.runMainThread(new Runnable() {
                     @Override
                     public void run() {
+                        if (currentHouseListPage > 1) {
+                            --currentHouseListPage;
+                        }
+                        isHouseLoadingMore = false;
                         if (isRefreshing) {
-                            //鍏抽棴涓嬫媺鍒锋柊鐨勫湀鍦�
-                            viewBinding.fragmentHouseSrl.setRefreshing(false);
+                            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();
+        }
+        //鑾峰彇浣忓畢(鐢电珯)ID鍒楄〃
+        HdlDeviceLogic.getInstance().getPowerStationDeviceList("", pageNo, pageSize, new CloudCallBeak<PageNumberObject<DeviceBean>>() {
+            @Override
+            public void onSuccess(PageNumberObject<DeviceBean> 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();
                         }
 
                     }
@@ -399,60 +619,38 @@
 
 
     /**
-     * 鐢宠鏉冮檺
+     * 娓呯┖缂撳瓨鏁版嵁
      */
-    private void requestPermissions(PermissionsResultCallback permissionsResultCallback) {
-
-
-        mPermissionsResultCallback = permissionsResultCallback;
-
-        String[] s = new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CAMERA,};
-        String[] ary = PermissionUtils.checkPermission(_mActivity, s);
-        if (ary.length > 0) {
-            requestPermissions(ary, PermissionUtils.STATUS_SUCCESS);
+    private void clearData() {
+        if (isClickPowerStationLabel) {
+            currentHouseListPage = 0;// 閲嶇疆褰撳墠鐢电珯鍒楄〃椤电爜
+            currentHouseListTotal = 0;// 閲嶇疆褰撳墠鐢电珯鍒楄〃鎬婚〉鐮�
+            if (houseListBeanIDList != null) {
+                houseListBeanIDList.clear(); //娓呯┖涓存椂缂撳瓨鍒楄〃
+            }
+            HdlResidenceLogic.getInstance().clearHouseList(); //琛ㄧず寮哄埗娓呯┖鎵�鏈夌紦瀛樹俊鎭�
         } else {
-            if (mPermissionsResultCallback != null) {
-                mPermissionsResultCallback.succeed();
+            currentDeviceListPage = 0; // 閲嶇疆褰撳墠璁惧鍒楄〃椤电爜
+            currentDeviceListTotal = 0; // 閲嶇疆璁惧鍒楄〃鎬婚〉鐮�
+            if (deviceInfoList != null) {
+                deviceInfoList.clear();//娓呯┖涓存椂缂撳瓨鍒楄〃
             }
+            HdlDeviceLogic.getInstance().clearDeviceList(); //琛ㄧず寮哄埗娓呯┖鎵�鏈夌紦瀛樹俊鎭�
         }
     }
 
-    @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();
-
-    }
 
     /**
      * 娌℃湁鐢电珯鍒楄〃鐨勬牱寮�
      */
-    private void nullDataUpdateUi(List<HouseIdBean> list) {
-        HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.nullDataIc.getRoot(), viewBinding.nullDataIc.nullDataGifAnimationIv, viewBinding.nullDataIc.nullDataTv, getString(R.string.my_power_station_data_null), list != null && list.size() > 0);
+    private void nullDataUpdateUi() {
+        boolean is_data;
+        if (isClickPowerStationLabel) {
+            is_data = houseListBeanIDList != null && houseListBeanIDList.size() > 0;
+        } else {
+            is_data = deviceInfoList != null && deviceInfoList.size() > 0;
+        }
+        HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.nullDataIc.getRoot(), viewBinding.nullDataIc.nullDataGifAnimationIv, viewBinding.nullDataIc.nullDataTv, getString(R.string.my_power_station_data_null), is_data);
     }
 
     /**
@@ -499,7 +697,7 @@
                 HdlResidenceLogic.getInstance().delHouseId(homeId);
                 initData();//鍒濆鍖栫紦瀛樻暟鎹�
                 houseInfoAdapter.setList(houseListBeanIDList);//閲嶆柊鍒锋柊鍒楄〃
-                nullDataUpdateUi(houseListBeanIDList);//妫�娴嬫暟鎹槸鍚︿负绌�
+                nullDataUpdateUi();//妫�娴嬫暟鎹槸鍚︿负绌�
             }
 
             @Override
@@ -512,4 +710,36 @@
     }
 
 
+    @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