From 8814f3f0828e6ac652a29cc9de9f971fd55bca5b Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 07 五月 2025 14:54:42 +0800
Subject: [PATCH] 2025年05月07日14:54:39

---
 app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java |  505 +++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 336 insertions(+), 169 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
index 8f3c909..d5a58ef 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
@@ -1,14 +1,20 @@
 package com.hdl.photovoltaic.ui.powerstation;
 
-import android.app.Dialog;
-import android.content.DialogInterface;
+import android.Manifest;
+import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
+import android.location.LocationManager;
+import android.os.AsyncTask;
 import android.os.Bundle;
+import android.provider.Settings;
+import android.text.TextUtils;
+import android.util.Log;
 import android.view.View;
-import android.view.Window;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.RelativeLayout;
+import android.widget.TextView;
 
 import androidx.annotation.NonNull;
 import androidx.appcompat.content.res.AppCompatResources;
@@ -18,12 +24,14 @@
 
 import com.google.gson.Gson;
 import com.hdl.linkpm.sdk.core.exception.HDLException;
+import com.hdl.photovoltaic.HDLApp;
 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.DebugStatus;
 import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch;
 import com.hdl.photovoltaic.enums.LowerTagType;
 import com.hdl.photovoltaic.enums.PowerStationStatus;
@@ -32,10 +40,11 @@
 import com.hdl.photovoltaic.enums.SortValue;
 import com.hdl.photovoltaic.listener.CloudCallBeak;
 import com.hdl.photovoltaic.listener.LinkCallBack;
+import com.hdl.photovoltaic.listener.OnCallBeak;
 import com.hdl.photovoltaic.other.HdlCommonLogic;
 import com.hdl.photovoltaic.other.HdlDeviceLogic;
+import com.hdl.photovoltaic.other.HdlDialogLogic;
 import com.hdl.photovoltaic.other.HdlLogLogic;
-import com.hdl.photovoltaic.other.HdlOtaLogic;
 import com.hdl.photovoltaic.other.HdlResidenceLogic;
 import com.hdl.photovoltaic.other.HdlThreadLogic;
 import com.hdl.photovoltaic.other.HdlUniLogic;
@@ -45,10 +54,14 @@
 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.GPSManagerUtils;
 import com.hdl.photovoltaic.utils.PermissionUtils;
 import com.hdl.photovoltaic.utils.URLEncodingUtils;
+import com.hdl.photovoltaic.widget.ConfirmationCancelDialog;
 import com.hdl.photovoltaic.widget.DefaultFilteringDialog;
 import com.hdl.photovoltaic.widget.DelayedConfirmationCancelDialog;
+import com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout;
+import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder;
 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;
@@ -90,10 +103,10 @@
     private String value = SortValue.all;//descending:闄嶅簭,ascending:鍗囧簭
     private String installedCapacityMinValue = "";//鏈�灏忕粍涓插閲�(瑁呮満瀹归噺)
     private String installedCapacityMaxValue = "";//鏈�澶х粍涓插閲�(瑁呮満瀹归噺)
-    private String gridTypeValue = "";//骞剁綉鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,FULL_GRID:骞剁綉,OFFLINE:绂荤綉)
+    private String screeningConditionStatus = DebugStatus.All;//绛涢�夋潯浠剁姸鎬�
     private String powerStationStatusValue = PowerStationStatus.All;//鐢电珯鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,1:姝e父(杩愯),2:绂荤嚎,3:寰呮帴鍏�,4:鏁呴殰)
 
-    private final long pageSize = 20;//椤垫暟
+    private final long pageSize = 100;//涓�椤靛ぇ灏�
 
     /**
      * 杩樺師鏉′欢鐨勫垵濮嬪寲鐘舵��
@@ -103,7 +116,7 @@
         value = SortValue.all;
         installedCapacityMinValue = "";
         installedCapacityMaxValue = "";
-        gridTypeValue = "";
+        screeningConditionStatus = DebugStatus.All;
         powerStationStatusValue = PowerStationStatus.All;
     }
 
@@ -115,7 +128,7 @@
 
     @Override
     public void onBindView(Bundle savedInstanceState) {
-        getStatusOverview();
+//        getStatusOverview();
         initData();
         //鍒濆鍖�
         initView();
@@ -136,7 +149,7 @@
                 selectedTitleLabelStyle();
                 initializationState();
                 getStatusOverview();
-                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
 
             }
         });
@@ -156,48 +169,52 @@
         viewBinding.allLl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                if (powerStationStatusValue.equals(PowerStationStatus.All)) {
+                    return;
+                }
                 powerStationStatusValue = PowerStationStatus.All;
-                viewBinding.allLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_yes_ffffff));
-                viewBinding.faultsLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-                viewBinding.offlineLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-                viewBinding.connectedLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv);
+                getStatusOverview();
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
             }
         });
         //鏁呴殰
         viewBinding.faultsLl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                if (powerStationStatusValue.equals(PowerStationStatus.malfunction)) {
+                    return;
+                }
                 powerStationStatusValue = PowerStationStatus.malfunction;
-                viewBinding.allLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-                viewBinding.faultsLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_yes_ffffff));
-                viewBinding.offlineLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-                viewBinding.connectedLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                stationStatusStyle(viewBinding.faultsLl, viewBinding.faultsDesTv);
+                getStatusOverview();
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
             }
         });
         //绂荤嚎
         viewBinding.offlineLl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                if (powerStationStatusValue.equals(PowerStationStatus.off)) {
+                    return;
+                }
                 powerStationStatusValue = PowerStationStatus.off;
-                viewBinding.allLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-                viewBinding.faultsLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-                viewBinding.offlineLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_yes_ffffff));
-                viewBinding.connectedLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                stationStatusStyle(viewBinding.offlineLl, viewBinding.offlineDesTv);
+                getStatusOverview();
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
             }
         });
         //寰呮帴鍏�
         viewBinding.connectedLl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                if (powerStationStatusValue.equals(PowerStationStatus.connecting)) {
+                    return;
+                }
                 powerStationStatusValue = PowerStationStatus.connecting;
-                viewBinding.allLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-                viewBinding.faultsLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-                viewBinding.offlineLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-                viewBinding.connectedLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_yes_ffffff));
-                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                stationStatusStyle(viewBinding.connectedLl, viewBinding.connectedDesTv);
+                getStatusOverview();
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
             }
         });
 
@@ -205,8 +222,14 @@
         viewBinding.addIv.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
-                HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+
+                requestPermissions(new OnCallBeak() {
+                    @Override
+                    public void onClickCallBeak() {
+//                        UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
+//                        HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+                    }
+                });
 
             }
         });
@@ -225,50 +248,17 @@
             public void onClick(View v) {
                 DefaultFilteringDialog defaultFilteringDialog = new DefaultFilteringDialog(_mActivity);
                 defaultFilteringDialog.show();
-                defaultFilteringDialog.initState(installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue);
+                defaultFilteringDialog.initState(installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus);
                 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);
+                        screeningConditionStatus = state;//璋冭瘯鐘舵��(鍏ㄩ儴;璋冭瘯涓�;璋冭瘯瀹屾垚;宸蹭氦浠�;鎺堟潈璋冭瘯)
+                        getStatusOverview();
+                        loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, 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);
-                    }
-                }
             }
         });
         //鐢电珯璇︽儏杩涘叆,鍒犻櫎鐢电珯,绉诲姩鐢电珯浣嶇疆
@@ -276,12 +266,11 @@
             @Override
             public void onClick(int position, HouseIdBean houseIdBean) {
                 //鐐瑰嚮浣忓畢璇︽儏
-                HdlLogLogic.print("鐐瑰嚮浣忓畢璇︽儏---" + new Gson().toJson(houseIdBean), false);
                 UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(0);
                 HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true);
                 String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS + "?homeId=" + houseIdBean.getHomeId() + "&homeName=" + houseIdBean.getHomeName() + "&powerStationStatus=" + houseIdBean.getPowerStationStatus();
                 HdlUniLogic.getInstance().openUniMP(path, null);
-
+                HdlLogLogic.print("鐐瑰嚮浣忓畢璇︽儏---" + new Gson().toJson(houseIdBean), false);
             }
 
             @Override
@@ -369,33 +358,40 @@
 
             }
         });
-        //鐢电珯缂栬緫鎸夐挳
-        viewBinding.editIv.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                startActivity(HouseListEditActivity.class);
-            }
-        });
-        //鐢电珯鍚嶇О绛涢��
+        //PV绛涢��
         viewBinding.stationNameRl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 boolean isSelected = !v.isSelected();
-                screenIconState(viewBinding.stationNameRl, viewBinding.stationNameIv, isSelected);
-                key = SortType.homeNameSort;
+                screeningConditionStyle(viewBinding.stationNameRl, viewBinding.stationNameIv, isSelected);
+                key = SortType.installedCapacitySort;
                 value = isSelected ? SortValue.ascending : SortValue.descending;
-                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                getStatusOverview();
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
             }
         });
-        //鐢电珯鍙戠數鍔熺巼绛涢��
+        //棰濆畾鍔熺巼绛涢��
         viewBinding.stationPowerRl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 boolean isSelected = !v.isSelected();
-                screenIconState(viewBinding.stationPowerRl, viewBinding.stationPowerIv, isSelected);
-                key = SortType.powerSort;
+                screeningConditionStyle(viewBinding.stationPowerRl, viewBinding.stationPowerIv, isSelected);
+                key = SortType.invPowerSort;
                 value = isSelected ? SortValue.ascending : SortValue.descending;
-                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                getStatusOverview();
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
+            }
+        });
+        //鐢电珯鐢垫睜瀹归噺绛涢��
+        viewBinding.stationMonthRl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                boolean isSelected = !v.isSelected();
+                screeningConditionStyle(viewBinding.stationMonthRl, viewBinding.stationMonthIv, isSelected);
+                key = SortType.batteryCapacitySort;
+                value = isSelected ? SortValue.ascending : SortValue.descending;
+                getStatusOverview();
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
             }
         });
         //鐢电珯褰撴棩鍙戠數閲忕瓫閫�
@@ -403,21 +399,11 @@
             @Override
             public void onClick(View v) {
                 boolean isSelected = !v.isSelected();
-                screenIconState(viewBinding.stationDayRl, viewBinding.stationDayIv, isSelected);
+                screeningConditionStyle(viewBinding.stationDayRl, viewBinding.stationDayIv, 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();
-                screenIconState(viewBinding.stationMonthRl, viewBinding.stationMonthIv, isSelected);
-                key = SortType.monthElectricitySort;
-                value = isSelected ? SortValue.ascending : SortValue.descending;
-                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                getStatusOverview();
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
             }
         });
         //璁惧鐐瑰嚮
@@ -451,7 +437,17 @@
                 HdlDeviceLogic.getInstance().setDeviceRemoteInfo(newList, deviceBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() {
                     @Override
                     public void onSuccess(List<GatewayBean> obj) {
+
                         GatewayBean newGatewayBean = HDLLinkLocalGateway.getInstance().getLocalGateway(deviceBean.getOsn());
+                        if (newGatewayBean == null) {
+                            HdlThreadLogic.toast(_mActivity, getString(R.string.device_off));
+                            return;
+                        }
+                        if (TextUtils.isEmpty(newGatewayBean.getGatewayId()) || TextUtils.isEmpty(newGatewayBean.getAesKey())) {
+                            //杩欓噷鍙敮鎸佽繙绋嬭皟璇曪紝杩滅▼鎷夸笉鍒癿qtt閫氳绉橀挜浠ュ強gatewayId锛�
+                            HdlThreadLogic.toast(_mActivity, getString(R.string.Device_failed_to_certificate) + "(124004)");
+                            return;
+                        }
                         String jsonEncryption = URLEncodingUtils.encodeURIComponent(new Gson().toJson(newGatewayBean));
                         String path = HDLUniMP.UNI_EVENT_OPEN_DEVICE_DETAILS + "?inverterInfo=" + jsonEncryption;
                         HdlUniLogic.getInstance().openUniMP(path, null);
@@ -462,38 +458,6 @@
 
                     }
                 });
-            }
-        });
-        //璁惧璁剧疆涓嬫媺绠ご棰滆壊
-        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);
-                    }
-                }
             }
         });
         //璁惧鎼滅储
@@ -508,14 +472,36 @@
 
     }
 
+
     /**
-     * 鏇存柊绛涢�夋潯浠剁姸鎬�
+     * 鏇存柊绛涢�夌數绔欑姸鎬佹牱寮�
+     *
+     * @param ll 缁勪欢鍚嶇О
+     * @param tv 缁勪欢鍚嶇О
+     */
+    private void stationStatusStyle(LinearLayout ll, TextView tv) {
+        viewBinding.allLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
+        viewBinding.faultsLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
+        viewBinding.offlineLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
+        viewBinding.connectedLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
+        viewBinding.allDesTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B));
+        viewBinding.faultsDesTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B));
+        viewBinding.offlineDesTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B));
+        viewBinding.connectedDesTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B));
+
+        ll.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_yes_ffffff));
+        tv.setTextColor(getResources().getColor(R.color.text_FFACACAC));
+
+    }
+
+    /**
+     * 鏇存柊绛涢�夋潯浠剁姸鎬佹牱寮�
      *
      * @param relativeLayout 缁勪欢鍚嶇О
      * @param imageView      缁勪欢鍚嶇О
      * @param isSelected     鐘舵��
      */
-    private void screenIconState(RelativeLayout relativeLayout, ImageView imageView, boolean isSelected) {
+    private void screeningConditionStyle(RelativeLayout relativeLayout, ImageView imageView, boolean isSelected) {
         viewBinding.stationNameRl.setSelected(false);
         viewBinding.stationNameIv.setSelected(false);
         viewBinding.stationPowerRl.setSelected(false);
@@ -528,13 +514,12 @@
         imageView.setSelected(isSelected);
     }
 
+
     private void initView() {
         viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);
         viewBinding.deviceLabelParent.setVisibility(View.GONE);
-        viewBinding.allLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_yes_ffffff));
-        viewBinding.faultsLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-        viewBinding.offlineLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-        viewBinding.connectedLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
+
+        stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv);
         //鐢电珯鏍囩
         houseInfoAdapter = new HouseInfoAdapter(_mActivity);
         viewBinding.fragmentHouseSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
@@ -545,7 +530,12 @@
         deviceInfoAdapter = new DeviceInfoAdapter(_mActivity);
         viewBinding.fragmentDeviceSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
         viewBinding.fragmentDeviceSrlListRc.setAdapter(deviceInfoAdapter);
+        //
 //        this.nullDataUpdateUi();
+        //涓嬫媺鍒锋柊浣忓畢鐨勯�昏緫
+        pullToRefreshHome();
+        //涓嬫媺鍒锋柊璁惧鐨勯�昏緫
+        pullToRefreshDevice();
 
     }
 
@@ -603,7 +593,7 @@
                 // 鍙栨秷绮樻�т簨浠�
                 EventBus.getDefault().removeStickyEvent(eventBus);
                 //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
-                loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
                 if (eventBus.getData() != null) {
                     Gson gson = new Gson();
                     String json = eventBus.getData().toString();
@@ -647,7 +637,8 @@
 //                if (MqttRecvClient.getInstance() != null) {
 //                    MqttRecvClient.getInstance().removeAllTopic();
 //                }
-                loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+
+                loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
             }
         } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) {
             // 鍙栨秷绮樻�т簨浠�
@@ -661,8 +652,8 @@
             }
             String homeId = eventBus.getData().toString();
             //杩涘幓浣忓畢璇︽儏uni璇诲彇閫嗗彉鍣ㄥ垪琛ㄦ垚鍔熷悗閫氱煡
-            for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).size(); i++) {
-                String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).get(i).getGatewayId();
+            for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId, null).size(); i++) {
+                String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId, null).get(i).getGatewayId();
                 //瀛楃涓叉槸鑷繁鎸夎鍒欐嫾鎺ョ殑,閲岄潰娉ㄥ唽涓婚鏃朵細瑙f瀽瀛楃涓�,鍙嬁getGatewayId()鍊�;
                 String topic = "/user/" + gatewayId + "/#";
                 //杩涘幓浣忓畢璇︽儏寮�濮嬭闃呬富棰�
@@ -688,27 +679,27 @@
                 isClickPowerStationLabel = true;
                 selectedTitleLabelStyle();
                 initializationState();
+                stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv);
                 getStatusOverview();
-                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
             } else if (eventBus.getType().equals(ConstantManage.station_page)) {
+                // 鍙栨秷绮樻�т簨浠�
+                EventBus.getDefault().removeStickyEvent(eventBus);
+                isClickPowerStationLabel = true;
+                selectedTitleLabelStyle();
+                powerStationStatusValue = eventBus.getData() == null ? "" : eventBus.getData().toString();
                 //閫氳繃棣栭〉鐢电珯杩涙潵鐨�
                 if (eventBus.getData().equals(PowerStationStatus.All)) {
-                    isClickPowerStationLabel = true;
-                    selectedTitleLabelStyle();
-                    viewBinding.allLl.performClick();
+                    stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv);
                 } else if (eventBus.getData().equals(PowerStationStatus.malfunction)) {
-                    isClickPowerStationLabel = true;
-                    selectedTitleLabelStyle();
-                    viewBinding.faultsLl.performClick();
+                    stationStatusStyle(viewBinding.faultsLl, viewBinding.faultsDesTv);
                 } else if (eventBus.getData().equals(PowerStationStatus.off)) {
-                    isClickPowerStationLabel = true;
-                    selectedTitleLabelStyle();
-                    viewBinding.offlineLl.performClick();
+                    stationStatusStyle(viewBinding.offlineLl, viewBinding.offlineDesTv);
                 } else if (eventBus.getData().equals(PowerStationStatus.connecting)) {
-                    isClickPowerStationLabel = true;
-                    selectedTitleLabelStyle();
-                    viewBinding.connectedLl.performClick();
+                    stationStatusStyle(viewBinding.connectedLl, viewBinding.connectedDesTv);
                 }
+                getStatusOverview();
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
             } else if (eventBus.getType().equals(ConstantManage.station_edit)) {
                 //缂栬緫鍚庢洿鏂颁竴涓嬩綇瀹呭垪琛�
                 //loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
@@ -727,7 +718,7 @@
      * 鐢电珯鐘舵�佹瑙�
      */
     private void getStatusOverview() {
-        HdlResidenceLogic.getInstance().getStatusOverview(new CloudCallBeak<StatusOverviewBean>() {
+        HdlResidenceLogic.getInstance().getStatusOverview(screeningConditionStatus, installedCapacityMinValue, installedCapacityMaxValue, new CloudCallBeak<StatusOverviewBean>() {
             @Override
             public void onSuccess(StatusOverviewBean statusOverviewBean) {
                 if (statusOverviewBean == null) {
@@ -750,15 +741,16 @@
     /**
      * 鍒锋柊UI锛堢數绔欙級
      *
-     * @param isRefreshing         琛ㄧず鏄笅鎷夊埛鏂扮殑
+     * @param isRefreshing         鏄惁鏄剧ず鍔犺浇妗嗭紙true鏄剧ず锛宖alse涓嶆樉绀猴級
      * @param key                  鍙戠數鍔熺巼鎺掑簭(powerSort);
      *                             浠婃棩鍙戠數閲忔帓搴�(todayElectricitySort);
      *                             鍒涘缓鏃堕棿鎺掑簭(createTimeSort);
+     *                             鐢垫睜瀹归噺鎺掑簭(batteryCapacitySort);
      * @param keyValue             (descending:闄嶅簭
      *                             ascending:鍗囧簭),
      * @param installedCapacityMin 鏈�灏忕粍涓插閲�(瑁呮満瀹归噺)
      * @param installedCapacityMax 鏈�澶х粍涓插閲�(瑁呮満瀹归噺)
-     * @param gridType             骞剁綉鐘舵�� (鍏ㄩ儴 锛�"";FULL_GRID 锛� 骞剁綉;OFFLINE 锛氱缃�)
+     * @param gridType             璋冭瘯鐘舵��(鍏ㄩ儴;璋冭瘯涓�;璋冭瘯瀹屾垚;宸蹭氦浠�;鎺堟潈璋冭瘯)
      * @param powerStationStatus   鐢电珯鐘舵�� (鍏ㄩ儴  锛�"";1 锛� 姝e父;2 锛� 绂荤嚎; 3 锛� 寰呮帴鍏�;4 锛� 鏁呴殰)
      * @param pageNo               椤电爜
      * @param isClear              鏄惁娓呴櫎鏁版嵁
@@ -819,7 +811,7 @@
                         if (isRefreshing) {
                             hideLoading();
                         }
-
+                        HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")");
                     }
                 }, _mActivity, ShowErrorMode.YES);
             }
@@ -829,7 +821,7 @@
     /**
      * 鍒锋柊UI锛堣澶囷級
      *
-     * @param isRefreshing 琛ㄧず鏄笅鎷夊埛鏂扮殑
+     * @param isRefreshing 鏄惁鏄剧ず鍔犺浇妗嗭紙true鏄剧ず锛宖alse涓嶆樉绀猴級
      * @param pageNo       椤电爜
      * @param isClear      true琛ㄧず娓呯┖缂撳瓨
      */
@@ -888,6 +880,7 @@
                         if (isRefreshing) {
                             hideLoading();
                         }
+                        HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")");
                     }
                 }, _mActivity, ShowErrorMode.YES);
             }
@@ -924,12 +917,12 @@
         boolean is_data;
         String tipText = "";
         if (isClickPowerStationLabel) {
-            is_data = houseListBeanIDList != null && houseListBeanIDList.size() > 0;
+            is_data = houseListBeanIDList != null && !houseListBeanIDList.isEmpty();
             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;
+            is_data = deviceInfoList != null && !deviceInfoList.isEmpty();
             tipText = getString(R.string.no_equipment);
 
             HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.deviceNullDataIc.getRoot(), viewBinding.deviceNullDataIc.nullDataGifAnimationIv, viewBinding.deviceNullDataIc.nullDataTv, tipText, is_data);
@@ -999,13 +992,18 @@
         if (requestCode == PermissionUtils.STATUS_SUCCESS) {
             for (int i = 0; i < permissions.length; i++) {
                 if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
-                    if (mPermissionsResultCallback != null) {
-                        mPermissionsResultCallback.succeed();
+                    switch (permissions[i]) {
+                        case Manifest.permission.ACCESS_FINE_LOCATION: {
+                            UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
+                            HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+                            locationUpdates();
+                        }
+                        break;
                     }
+
                 } else {
-                    if (mPermissionsResultCallback != null) {
-                        mPermissionsResultCallback.failing();
-                    }
+                    HdlDialogLogic.getInstance().showSettingPermissionDialog(_mActivity, _mActivity.getString(R.string.set_location_permissions));
+                    break;
                 }
 
             }
@@ -1013,16 +1011,185 @@
 
     }
 
+    public void requestPermissions(OnCallBeak onCallBeak) {
 
-    private PermissionsResultCallback mPermissionsResultCallback;
+        //ACCESS_FINE_LOCATION	鍏佽浣跨敤GPS瀹氫綅
+        //ACCESS_COARSE_LOCATION	鍏佽浣跨敤WIFI鐑偣鎴栧熀绔欐潵鑾峰彇绮楃暐鐨勫畾浣�
+        String[] ary = PermissionUtils.checkPermission(_mActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION});
+        if (ary.length > 0) {
+            this.requestPermissions(ary, PermissionUtils.STATUS_SUCCESS);
+        } else {
 
-    public interface PermissionsResultCallback {
+            UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
+            HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+            locationUpdates();
 
-        void succeed();
 
-        void failing();
+        }
 
     }
 
+    /**
+     * 鍒濆鍖栥�愬紑鍚畾浣嶃�戝拰銆愪綅缃俊鎭�戞潈闄�
+     */
+    private void locationUpdates() {
+        // 鍒濆鍖朙ocationManager瀵硅薄
+        LocationManager locationManager = (LocationManager) _mActivity.getSystemService(Context.LOCATION_SERVICE);
+        GPSManagerUtils.getInstance().getLocation(_mActivity);
+        // 鍒ゆ柇璁惧鏄惁鏀寔瀹氫綅鍔熻兘
+        if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
+            // 鎻愮ず鐢ㄦ埛鎵撳紑瀹氫綅鍔熻兘鎴栬�呭紩瀵肩敤鎴峰幓绯荤粺璁剧疆椤甸潰鎵撳紑瀹氫綅鍔熻兘
+            ConfirmationCancelDialog confirmationCancelDialog = new ConfirmationCancelDialog(_mActivity);
+            confirmationCancelDialog.setContent(getString(R.string.system_positioning_switch));
+            confirmationCancelDialog.setConfirmation(getString(R.string.go_to_settings));
+            confirmationCancelDialog.show();
+            confirmationCancelDialog.isHideTitle(true);
+            confirmationCancelDialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() {
+                @Override
+                public void Confirm() {
+                    confirmationCancelDialog.dismiss();
+                    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                    HDLApp.getInstance().startActivity(intent);
+
+                }
+            });
+            confirmationCancelDialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() {
+                @Override
+                public void Cancel() {
+                    confirmationCancelDialog.dismiss();
+                }
+            });
+
+        }
+
+    }
+
+
+    /**
+     * 涓嬫媺鍒锋柊銆愪綇瀹呫�戠殑閫昏緫
+     */
+    protected void pullToRefreshHome() {
+        viewBinding.fragmentHouseSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() {
+            @Override
+            public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) {
+                new AsyncTask<Void, Void, Void>() {
+
+                    @Override
+                    protected Void doInBackground(Void... params) {
+                        try {
+                            Thread.sleep(1000);
+                        } catch (InterruptedException e) {
+                            e.printStackTrace();
+                        }
+                        return null;
+                    }
+
+                    @Override
+                    protected void onPostExecute(Void aVoid) {
+                        // 鎵ц浠诲姟锛堝鏇存柊UI銆佽烦杞瓑锛�
+                        viewBinding.fragmentHouseSrl.endRefreshing();
+                        //鍔犺浇鏈�鏂版暟鎹畬鎴�
+                        loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
+                        getStatusOverview();
+                    }
+                }.execute();
+
+
+            }
+
+
+            @Override
+            public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) {
+                new AsyncTask<Void, Void, Void>() {
+                    @Override
+                    protected Void doInBackground(Void... params) {
+                        try {
+                            Thread.sleep(10);
+                        } catch (InterruptedException e) {
+                            e.printStackTrace();
+                        }
+                        return null;
+                    }
+
+                    @Override
+                    protected void onPostExecute(Void aVoid) {
+                        viewBinding.fragmentHouseSrl.endLoadingMore();
+                        if (!isHouseLoadingMore) {
+                            // 婊戝姩鍒颁簡搴曢儴锛屾墽琛岀浉搴旂殑鎿嶄綔
+                            loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, ++currentHouseListPage, false);
+                        }
+                    }
+                }.execute();
+                return true;
+            }
+        });
+        HDLRefreshViewHolder hdlRefreshViewHolder = new HDLRefreshViewHolder(_mActivity, true);
+        hdlRefreshViewHolder.setPullDownImageResource(R.mipmap.loading_44);
+        hdlRefreshViewHolder.setChangeToReleaseRefreshAnimResId(R.drawable.loading_refresh);
+        hdlRefreshViewHolder.setRefreshingAnimResId(R.drawable.loading_refresh_end);
+        viewBinding.fragmentHouseSrl.setRefreshViewHolder(hdlRefreshViewHolder);
+    }
+
+    /**
+     * 涓嬫媺鍒锋柊銆愯澶囥�戠殑閫昏緫
+     */
+    protected void pullToRefreshDevice() {
+        viewBinding.fragmentDeviceSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() {
+            @Override
+            public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) {
+
+                new AsyncTask<Void, Void, Void>() {
+                    @Override
+                    protected Void doInBackground(Void... params) {
+                        try {
+                            Thread.sleep(1000);
+                        } catch (InterruptedException e) {
+                            e.printStackTrace();
+                        }
+                        return null;
+                    }
+
+                    @Override
+                    protected void onPostExecute(Void aVoid) {
+                        viewBinding.fragmentDeviceSrl.endRefreshing();
+                        loadNextPageDeviceList(false, 1, true);
+                    }
+                }.execute();
+            }
+
+            @Override
+            public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) {
+                new AsyncTask<Void, Void, Void>() {
+                    @Override
+                    protected Void doInBackground(Void... params) {
+                        try {
+                            Thread.sleep(10);
+                        } catch (InterruptedException e) {
+                            e.printStackTrace();
+                        }
+                        return null;
+                    }
+
+                    @Override
+                    protected void onPostExecute(Void aVoid) {
+                        // 鎵ц浠诲姟锛堝鏇存柊UI銆佽烦杞瓑锛�
+                        viewBinding.fragmentDeviceSrl.endLoadingMore();
+                        if (!isDeviceLoadingMore) {
+                            // 婊戝姩鍒颁簡搴曢儴锛屾墽琛岀浉搴旂殑鎿嶄綔
+                            loadNextPageDeviceList(false, ++currentDeviceListPage, false);
+                        }
+                    }
+                }.execute();
+                return true;
+            }
+        });
+        HDLRefreshViewHolder hdlRefreshViewHolder = new HDLRefreshViewHolder(_mActivity, true);
+        hdlRefreshViewHolder.setPullDownImageResource(R.mipmap.loading_44);
+        hdlRefreshViewHolder.setChangeToReleaseRefreshAnimResId(R.drawable.loading_refresh);
+        hdlRefreshViewHolder.setRefreshingAnimResId(R.drawable.loading_refresh_end);
+        viewBinding.fragmentDeviceSrl.setRefreshViewHolder(hdlRefreshViewHolder);
+    }
+
 
 }

--
Gitblit v1.8.0