wjc
2025-04-30 f91ef956cf482ed4ce0885dc47794b783c20c415
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
@@ -1,10 +1,23 @@
package com.hdl.photovoltaic.ui.powerstation;
import android.Manifest;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.SystemClock;
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;
@@ -15,11 +28,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;
@@ -28,9 +44,12 @@
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;
@@ -40,10 +59,15 @@
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.ProcessManagerUtils;
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;
@@ -85,10 +109,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:正常(运行),2:离线,3:待接入,4:故障)
    private final long pageSize = 20;//页数
    private final long pageSize = 100;//一页大小
    /**
     * 还原条件的初始化状态
@@ -98,7 +122,7 @@
        value = SortValue.all;
        installedCapacityMinValue = "";
        installedCapacityMaxValue = "";
        gridTypeValue = "";
        screeningConditionStatus = DebugStatus.All;
        powerStationStatusValue = PowerStationStatus.All;
    }
@@ -110,7 +134,7 @@
    @Override
    public void onBindView(Bundle savedInstanceState) {
        getStatusOverview();
//        getStatusOverview();
        initData();
        //初始化
        initView();
@@ -131,7 +155,7 @@
                selectedTitleLabelStyle();
                initializationState();
                getStatusOverview();
                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
            }
        });
@@ -148,39 +172,55 @@
            }
        });
        //全部
        viewBinding.powerStationAllIl.parentLl.setOnClickListener(new View.OnClickListener() {
        viewBinding.allLl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (powerStationStatusValue.equals(PowerStationStatus.All)) {
                    return;
                }
                powerStationStatusValue = PowerStationStatus.All;
                selectedStationStateStyle(viewBinding.powerStationAllIl.parentLl, viewBinding.powerStationAllIl.stationTotalTv, viewBinding.powerStationAllIl.stationTitleTv, true);
                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.powerStationFaultsIl.parentLl.setOnClickListener(new View.OnClickListener() {
        viewBinding.faultsLl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (powerStationStatusValue.equals(PowerStationStatus.malfunction)) {
                    return;
                }
                powerStationStatusValue = PowerStationStatus.malfunction;
                selectedStationStateStyle(viewBinding.powerStationFaultsIl.parentLl, viewBinding.powerStationFaultsIl.stationTotalTv, viewBinding.powerStationFaultsIl.stationTitleTv, true);
                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.powerStationOfflineIl.parentLl.setOnClickListener(new View.OnClickListener() {
        viewBinding.offlineLl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (powerStationStatusValue.equals(PowerStationStatus.off)) {
                    return;
                }
                powerStationStatusValue = PowerStationStatus.off;
                selectedStationStateStyle(viewBinding.powerStationOfflineIl.parentLl, viewBinding.powerStationOfflineIl.stationTotalTv, viewBinding.powerStationOfflineIl.stationTitleTv, true);
                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.powerStationConnectedIl.parentLl.setOnClickListener(new View.OnClickListener() {
        viewBinding.connectedLl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (powerStationStatusValue.equals(PowerStationStatus.connecting)) {
                    return;
                }
                powerStationStatusValue = PowerStationStatus.connecting;
                selectedStationStateStyle(viewBinding.powerStationConnectedIl.parentLl, viewBinding.powerStationConnectedIl.stationTotalTv, viewBinding.powerStationConnectedIl.stationTitleTv, true);
                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);
            }
        });
@@ -188,7 +228,14 @@
        viewBinding.addIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                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);
                    }
                });
            }
        });
@@ -207,50 +254,16 @@
            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;//调试状态(全部;调试中;调试完成;已交付;授权调试)
                        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);
                    }
                }
            }
        });
        //电站详情进入,删除电站,移动电站位置
@@ -258,11 +271,11 @@
            @Override
            public void onClick(int position, HouseIdBean houseIdBean) {
                //点击住宅详情
                HdlLogLogic.print("点击住宅详情---" + new Gson().toJson(houseIdBean), false);
                HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
                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
@@ -350,23 +363,22 @@
            }
        });
        //电站编辑按钮
        viewBinding.editIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(HouseListEditActivity.class);
            }
        });
//        //电站编辑按钮
//        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;
                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);
                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
            }
        });
        //电站发电功率筛选
@@ -374,11 +386,23 @@
            @Override
            public void onClick(View v) {
                boolean isSelected = !v.isSelected();
                viewBinding.stationPowerRl.setSelected(isSelected);
                viewBinding.stationPowerIv.setSelected(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);
            }
        });
        //电站当日发电量筛选
@@ -386,23 +410,21 @@
            @Override
            public void onClick(View v) {
                boolean isSelected = !v.isSelected();
                viewBinding.stationDayRl.setSelected(isSelected);
                viewBinding.stationDayIv.setSelected(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);
                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();
                viewBinding.stationMonthRl.setSelected(isSelected);
                viewBinding.stationMonthIv.setSelected(isSelected);
                key = SortType.monthElectricitySort;
                screenIconState(viewBinding.stationMonthRl, viewBinding.stationMonthIv, isSelected);
                key = SortType.batteryCapacitySort;
                value = isSelected ? SortValue.ascending : SortValue.descending;
                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
            }
        });
        //设备点击
@@ -436,7 +458,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())) {
                            //这里只支持远程调试,远程拿不到mqtt通讯秘钥以及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);
@@ -447,38 +479,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);
                    }
                }
            }
        });
        //设备搜索
@@ -493,16 +493,54 @@
    }
    /**
     * 更新筛选电站状态样式
     *
     * @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 screeningConditionStyle(RelativeLayout relativeLayout, ImageView imageView, boolean isSelected) {
        viewBinding.stationNameRl.setSelected(false);
        viewBinding.stationNameIv.setSelected(false);
        viewBinding.stationPowerRl.setSelected(false);
        viewBinding.stationPowerIv.setSelected(false);
        viewBinding.stationDayRl.setSelected(false);
        viewBinding.stationDayIv.setSelected(false);
        viewBinding.stationMonthRl.setSelected(false);
        viewBinding.stationMonthIv.setSelected(false);
        relativeLayout.setSelected(isSelected);
        imageView.setSelected(isSelected);
    }
    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);
        stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv);
        //电站标签
        houseInfoAdapter = new HouseInfoAdapter(_mActivity);
        viewBinding.fragmentHouseSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
@@ -513,7 +551,12 @@
        deviceInfoAdapter = new DeviceInfoAdapter(_mActivity);
        viewBinding.fragmentDeviceSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
        viewBinding.fragmentDeviceSrlListRc.setAdapter(deviceInfoAdapter);
        this.nullDataUpdateUi();
        //
//        this.nullDataUpdateUi();
        //下拉刷新住宅的逻辑
        pullToRefreshHome();
        //下拉刷新设备的逻辑
        pullToRefreshDevice();
    }
@@ -522,8 +565,8 @@
     */
    private void selectedTitleLabelStyle() {
        if (isClickPowerStationLabel) {
            viewBinding.powerStationLabel.setTextAppearance(R.style.Text20Style);
            viewBinding.deviceLabel.setTextAppearance(R.style.Text16Style);
            viewBinding.powerStationLabel.setTextAppearance(R.style.Text18Style);
            viewBinding.deviceLabel.setTextAppearance(R.style.Text14Style);
//            viewBinding.editIv.setVisibility(View.VISIBLE);//编辑图标隐藏
            viewBinding.addIv.setVisibility(View.VISIBLE);//添加图标隐藏
            viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);//电站标签【父容器】显示
@@ -532,8 +575,8 @@
                viewBinding.deviceNullDataIc.getRoot().setVisibility(View.GONE);
            }
        } else {
            viewBinding.deviceLabel.setTextAppearance(R.style.Text20Style);
            viewBinding.powerStationLabel.setTextAppearance(R.style.Text16Style);
            viewBinding.deviceLabel.setTextAppearance(R.style.Text18Style);
            viewBinding.powerStationLabel.setTextAppearance(R.style.Text14Style);
//            viewBinding.editIv.setVisibility(View.GONE);//编辑图标隐藏
            viewBinding.addIv.setVisibility(View.GONE);//添加图标隐藏
            viewBinding.powerStationLabelParent.setVisibility(View.GONE);//电站标签【父容器】隐藏
@@ -545,40 +588,6 @@
    }
    /**
     * 显示选中状态样式
     *
     * @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) {
@@ -605,12 +614,12 @@
                // 取消粘性事件
                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();
                    HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class);
                    HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
                    HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true);
                }
            } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT.equals(eventBus.getType())) {
@@ -649,7 +658,7 @@
//                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())) {
            // 取消粘性事件
@@ -663,8 +672,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();
                //字符串是自己按规则拼接的,里面注册主题时会解析字符串,只拿getGatewayId()值;
                String topic = "/user/" + gatewayId + "/#";
                //进去住宅详情开始订阅主题
@@ -690,27 +699,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.powerStationAllIl.parentLl.performClick();
                    stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv);
                } else if (eventBus.getData().equals(PowerStationStatus.malfunction)) {
                    isClickPowerStationLabel = true;
                    selectedTitleLabelStyle();
                    viewBinding.powerStationFaultsIl.parentLl.performClick();
                    stationStatusStyle(viewBinding.faultsLl, viewBinding.faultsDesTv);
                } else if (eventBus.getData().equals(PowerStationStatus.off)) {
                    isClickPowerStationLabel = true;
                    selectedTitleLabelStyle();
                    viewBinding.powerStationOfflineIl.parentLl.performClick();
                    stationStatusStyle(viewBinding.offlineLl, viewBinding.offlineDesTv);
                } else if (eventBus.getData().equals(PowerStationStatus.connecting)) {
                    isClickPowerStationLabel = true;
                    selectedTitleLabelStyle();
                    viewBinding.powerStationConnectedIl.parentLl.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);
@@ -729,16 +738,16 @@
     * 电站状态概览
     */
    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) {
                    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()));
                viewBinding.allTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getTotal()));
                viewBinding.faultsTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getFault()));
                viewBinding.offlineTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getOffline()));
                viewBinding.connectedTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getConnecting()));
            }
            @Override
@@ -752,15 +761,16 @@
    /**
     * 刷新UI(电站)
     *
     * @param isRefreshing         表示是下拉刷新的
     * @param isRefreshing         是否显示加载框(true显示,false不显示)
     * @param key                  发电功率排序(powerSort);
     *                             今日发电量排序(todayElectricitySort);
     *                             创建时间排序(createTimeSort);
     *                             电池容量排序(batteryCapacitySort);
     * @param keyValue             (descending:降序
     *                             ascending:升序),
     * @param installedCapacityMin 最小组串容量(装机容量)
     * @param installedCapacityMax 最大组串容量(装机容量)
     * @param gridType             并网状态 (全部 :"";FULL_GRID : 并网;OFFLINE :离网)
     * @param gridType             调试状态(全部;调试中;调试完成;已交付;授权调试)
     * @param powerStationStatus   电站状态 (全部  :"";1 : 正常;2 : 离线; 3 : 待接入;4 : 故障)
     * @param pageNo               页码
     * @param isClear              是否清除数据
@@ -831,7 +841,7 @@
    /**
     * 刷新UI(设备)
     *
     * @param isRefreshing 表示是下拉刷新的
     * @param isRefreshing 是否显示加载框(true显示,false不显示)
     * @param pageNo       页码
     * @param isClear      true表示清空缓存
     */
@@ -926,12 +936,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);
@@ -1001,13 +1011,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;
                }
            }
@@ -1015,16 +1030,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() {
        // 初始化LocationManager对象
        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);
    }
}