wjc
7 天以前 0770fc4f03196a27e8f4c899a44da63bb1a683e2
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
@@ -8,6 +8,7 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -17,8 +18,6 @@
import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.google.gson.Gson;
import com.hdl.linkpm.sdk.core.exception.HDLException;
@@ -126,7 +125,7 @@
    @Override
    public void onBindView(Bundle savedInstanceState) {
        getStatusOverview();
//        getStatusOverview();
        initData();
        //初始化
        initView();
@@ -171,7 +170,7 @@
                    return;
                }
                powerStationStatusValue = PowerStationStatus.All;
                stationStatusStyle(viewBinding.allLl,viewBinding.allDesTv);
                stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv);
                getStatusOverview();
                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
            }
@@ -184,7 +183,7 @@
                    return;
                }
                powerStationStatusValue = PowerStationStatus.malfunction;
                stationStatusStyle(viewBinding.faultsLl,viewBinding.faultsDesTv);
                stationStatusStyle(viewBinding.faultsLl, viewBinding.faultsDesTv);
                getStatusOverview();
                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
            }
@@ -197,7 +196,7 @@
                    return;
                }
                powerStationStatusValue = PowerStationStatus.off;
                stationStatusStyle(viewBinding.offlineLl,viewBinding.offlineDesTv);
                stationStatusStyle(viewBinding.offlineLl, viewBinding.offlineDesTv);
                getStatusOverview();
                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
            }
@@ -210,7 +209,7 @@
                    return;
                }
                powerStationStatusValue = PowerStationStatus.connecting;
                stationStatusStyle(viewBinding.connectedLl,viewBinding.connectedDesTv);
                stationStatusStyle(viewBinding.connectedLl, viewBinding.connectedDesTv);
                getStatusOverview();
                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
            }
@@ -435,7 +434,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);
@@ -507,7 +516,7 @@
        viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);
        viewBinding.deviceLabelParent.setVisibility(View.GONE);
        stationStatusStyle(viewBinding.allLl,viewBinding.allDesTv);
        stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv);
        //电站标签
        houseInfoAdapter = new HouseInfoAdapter(_mActivity);
        viewBinding.fragmentHouseSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
@@ -580,15 +589,18 @@
            if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
                // 取消粘性事件
                EventBus.getDefault().removeStickyEvent(eventBus);
                //uin创建电站成功后通知
                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, true);
                }
//                HdlLogLogic.print("进来了---11111" + eventBus.getData().toString());
//                //uin创建电站成功后通知
//                loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
//                if (eventBus.getData() != null) {
//                    HdlLogLogic.print("进来了---" + eventBus.getData().toString());
//                    Gson gson = new Gson();
//                    String json = eventBus.getData().toString();
//                    HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class);
//                    HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true);
//                    HdlLogLogic.print("进来了---结束" + eventBus.getData().toString());
//
//                }
            } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT.equals(eventBus.getType())) {
                // 取消粘性事件
                EventBus.getDefault().removeStickyEvent(eventBus);
@@ -667,27 +679,27 @@
                isClickPowerStationLabel = true;
                selectedTitleLabelStyle();
                initializationState();
                stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv);
                getStatusOverview();
                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);
@@ -957,7 +969,7 @@
            @Override
            public void onSuccess(Boolean obj) {
                hideLoading();
                initializeInverter(list); //发起初始化指令给逆变器;(注意:只能是本地发送了(要搜索局域网逆变器列表,建立本地通讯通道),删除电站成功后,云端解绑逆变器的关系)
                initializeInverter(list); //发起初始化指令给逆变器;(注意:前面已先解绑云端逆变器,mqtt通道已断开,初始化只能是本地发送(先搜索局域网逆变器列表,建立本地通讯通道))
                HdlResidenceLogic.getInstance().delHouseId(homeId);//删除电站缓存
                initData();//初始化缓存数据
                houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//重新刷新列表
@@ -1078,7 +1090,7 @@
                        // 执行任务(如更新UI、跳转等)
                        viewBinding.fragmentHouseSrl.endRefreshing();
                        //加载最新数据完成
                        loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
                        loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
                        getStatusOverview();
                    }
                }.execute();
@@ -1141,7 +1153,7 @@
                    @Override
                    protected void onPostExecute(Void aVoid) {
                        viewBinding.fragmentDeviceSrl.endRefreshing();
                        loadNextPageDeviceList(true, 1, true);
                        loadNextPageDeviceList(false, 1, true);
                    }
                }.execute();
            }