From bae677bcbf12e6e7bff63baff362f3ce91184a62 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 09 五月 2024 17:49:33 +0800
Subject: [PATCH] 2024年05月09日17:49:28

---
 app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java |  152 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 96 insertions(+), 56 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 b850088..f32beb7 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
@@ -36,6 +36,7 @@
 import com.hdl.photovoltaic.ui.bean.HouseIdBean;
 import com.hdl.photovoltaic.uni.HDLUniMP;
 import com.hdl.photovoltaic.utils.PermissionUtils;
+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;
@@ -70,16 +71,10 @@
 
     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 String installedCapacityMinValue = "";//鏈�灏忕粍涓插閲�(瑁呮満瀹归噺)
+    private String installedCapacityMaxValue = "";//鏈�澶х粍涓插閲�(瑁呮満瀹归噺)
+    private String gridTypeValue = "";//骞剁綉鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,FULL_GRID:骞剁綉,OFFLINE:绂荤綉)
+    private String powerStationStatusValue = "";//鐢电珯鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,1:姝e父(杩愯),2:绂荤嚎,3:寰呮帴鍏�,4:鏁呴殰)
 
     private final long pageSize = 20;//椤垫暟
 
@@ -113,7 +108,7 @@
                 viewBinding.deviceLabel.setTextAppearance(R.style.Text16Style);
                 viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);
                 viewBinding.deviceLabelParent.setVisibility(View.GONE);//璁惧鏍囩闅愯棌
-                loadNextPageHouseList(true, 1, true);
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
             }
         });
         //璁惧鏍囩
@@ -142,7 +137,7 @@
 
             }
         });
-        //鐢电珯娣绘悳绱�
+        //鐢电珯鎼滅储
         viewBinding.powerStationSearchClickCl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -151,6 +146,25 @@
                 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);
         //鐢电珯涓嬫媺璇诲彇
@@ -158,7 +172,7 @@
             @Override
             public void onRefresh() {
                 viewBinding.fragmentHouseSrl.setRefreshing(false);
-                loadNextPageHouseList(true, 1, true);
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
             }
         });
         //鐢电珯涓婃媺璇诲彇
@@ -178,7 +192,7 @@
                     if (!isHouseLoadingMore) {
                         // 婊戝姩鍒颁簡搴曢儴锛屾墽琛岀浉搴旂殑鎿嶄綔
                         HdlLogLogic.print("--->婊戝姩鍒颁簡搴曢儴");
-                        loadNextPageHouseList(false, ++currentHouseListPage, false);
+                        loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, ++currentHouseListPage, false);
                     }
                 }
             }
@@ -421,7 +435,7 @@
         if (HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL.equals(eventBus.getTopic())) {
             if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
                 //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
-                loadNextPageHouseList(false, 1, true);
+                loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
                 if (eventBus.getData() != null) {
                     Gson gson = new Gson();
                     String json = eventBus.getData().toString();
@@ -460,7 +474,7 @@
             if (MqttRecvClient.getInstance() != null) {
                 MqttRecvClient.getInstance().removeAllTopic();
             }
-            loadNextPageHouseList(false, 1, true);
+            loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
 
         } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) {
             //杩涘幓浣忓畢璇︽儏uni璇诲彇閫嗗彉鍣ㄥ垪琛ㄦ垚鍔熷悗閫氱煡
@@ -475,7 +489,7 @@
             //鎺ユ敹澶栭儴鐐瑰嚮浜嬩欢
             if (eventBus.getType().equals(HomepageTitleTabSwitch.powerstation.toString())) {
                 HdlLogLogic.print("姝e湪鐐瑰嚮銆愮數绔欍��");
-                loadNextPageHouseList(true, 1, true);
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
             }
         }
     }
@@ -484,9 +498,28 @@
     /**
      * 鍒锋柊UI锛堢數绔欙級
      *
-     * @param isRefreshing 琛ㄧず鏄笅鎷夊埛鏂扮殑
+     * @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, long pageNo, boolean isClear) {
+    private void loadNextPageHouseList(boolean isRefreshing,
+                                       String key,
+                                       String keyValue,
+                                       String installedCapacityMin,
+                                       String installedCapacityMax,
+                                       String gridType,
+                                       String powerStationStatus,
+                                       long pageNo,
+                                       boolean isClear) {
         if (isClear) {
             clearData();
         }
@@ -502,50 +535,57 @@
         }
 
         //鑾峰彇浣忓畢(鐢电珯)ID鍒楄〃
-        HdlResidenceLogic.getInstance().getResidenceIdList(key, value, pageNo, pageSize, new CloudCallBeak<HdlResidenceLogic.HouseBeanClass>() {
-            @Override
-            public void onSuccess(HdlResidenceLogic.HouseBeanClass houseBeanClass) {
-                HdlThreadLogic.runMainThread(new Runnable() {
+        HdlResidenceLogic.getInstance().getResidenceIdList(
+                key,
+                keyValue,
+                installedCapacityMin,
+                installedCapacityMax,
+                gridType,
+                powerStationStatus,
+                pageNo, pageSize, new CloudCallBeak<HdlResidenceLogic.HouseBeanClass>() {
                     @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);
+                    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);
+                                    }
+                                }
+                                nullDataUpdateUi();
                             }
-                        }
-                        nullDataUpdateUi();
+                        }, _mActivity, ShowErrorMode.YES);
+
                     }
-                }, _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();
-                        }
+                    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);
                     }
-                }, _mActivity, ShowErrorMode.YES);
-            }
-        });
+                });
     }
 
     /**

--
Gitblit v1.8.0