mac
2023-12-29 27d994f4375f604ba7f49a5ba600882884d73126
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
@@ -2,7 +2,6 @@
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.hardware.camera2.CameraManager;
import android.os.Bundle;
@@ -20,18 +19,15 @@
import com.hdl.photovoltaic.config.UserConfigManage;
import com.hdl.photovoltaic.databinding.FragmentHouseListBinding;
import com.hdl.photovoltaic.base.CustomBaseFragment;
import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch;
import com.hdl.photovoltaic.enums.ShowErrorMode;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.other.HdlCommonLogic;
import com.hdl.photovoltaic.other.HdlDeviceLogic;
import com.hdl.photovoltaic.other.HdlLogLogic;
import com.hdl.photovoltaic.other.HdlResidenceLogic;
import com.hdl.photovoltaic.other.HdlThreadLogic;
import com.hdl.photovoltaic.other.HdlUniLogic;
import com.hdl.photovoltaic.ui.adapter.HouseInfoAdapter;
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
import com.hdl.photovoltaic.ui.bean.HouseInfoBean;
import com.hdl.photovoltaic.ui.device.FastScanActivity;
import com.hdl.photovoltaic.uni.HDLUniMP;
import com.hdl.photovoltaic.utils.PermissionUtils;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
@@ -116,13 +112,12 @@
            @Override
            public void onClick(int position, HouseIdBean houseIdBean) {
                //点击住宅详情
                HdlLogLogic.print("点击住宅详情===" + new Gson().toJson(houseIdBean), false);
                HdlLogLogic.print("点击住宅详情--->" + new Gson().toJson(houseIdBean), false);
                HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
                String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS
                        + "?homeId=" + houseIdBean.getHomeId()
                        + "&homeName=" + houseIdBean.getHomeName()
                        + "&powerStationStatus=" + houseIdBean.getPowerStationStatus()
                        + "&serverAddress=" + AppConfigManage.getUserRegionUrl();
                        + "&powerStationStatus=" + houseIdBean.getPowerStationStatus();
                HdlUniLogic.getInstance().openUniMP(path, null);
            }
@@ -139,15 +134,13 @@
        viewBinding.fragmentHouseSrlListRc.setAdapter(houseInfoAdapter);
        this.nullDataUpdateUi(houseListBeanIDList);
    }
    private void initData() {
        this.houseListBeanIDList = new ArrayList<>();
//        for (int i = 0; i < 11; i++) {
//            HouseListBean houseListBean = new HouseListBean();
//            houseListBean.setHomeName("电站" + i);
//            this.houseListBeanList.add(houseListBean);
//        }
        this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList());
    }
@@ -159,14 +152,41 @@
    @Override
    public void onEventMessage(BaseEventBus eventBus) {
        super.onEventMessage(eventBus);
        if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
            //uin创建电站成功后通知
            updateUIData(false);
            if (eventBus.getData() != null) {
                Gson gson = new Gson();
                String json = eventBus.getData().toString();
                HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class);
                HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
        if (HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL.equals(eventBus.getTopic())) {
            if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
                //uin创建电站成功后通知
                updateUIData(false);
                if (eventBus.getData() != null) {
                    Gson gson = new Gson();
                    String json = eventBus.getData().toString();
                    HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class);
                    HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
                }
            } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT.equals(eventBus.getType())) {
                //todo 现在默认刷新全部
                //uin编辑住宅通知
//                String homeId = HdlUniLogic.getInstance().getKeyValue("homeId", eventBus.getData());
//                String home_name = HdlUniLogic.getInstance().getKeyValue("powerStationName", eventBus.getData());
//                if (TextUtils.isEmpty(homeId) || TextUtils.isEmpty(home_name)) {
//                    return;
//                }
//                int index = -1;
//                for (int i = 0; i < houseListBeanIDList.size(); i++) {
//                    HouseIdBean houseIdBean = houseListBeanIDList.get(i);
//                    if (houseIdBean.getHomeId().equals(homeId)) {
//                        index = i;
//                        houseIdBean.setHomeName(home_name);
//                        break;
//                    }
//                }
//                if (index > -1) {
//                    if (houseInfoAdapter != null) {
//                        //更新单个数据
//                        houseInfoAdapter.notifyItemChanged(index);
//                    }
//                }
            }
        } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE.equals(eventBus.getType())) {
@@ -174,18 +194,20 @@
            if (MqttRecvClient.getInstance() != null) {
                MqttRecvClient.getInstance().removeAllTopic();
            }
            updateUIData(false);
        } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) {
            //进去住宅详情uni读取逆变器列表成功后通知
            for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().size(); i++) {
                //String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().get(i).getGatewayId();
                //字符串是自己按规则拼接的,里面注册主题时会解析字符串,只拿getGatewayId()值;
                //String topic = "/user/" + gatewayId+"/1";
                //进去住宅详情开始订阅主题
                MqttRecvClient.getInstance().checkAndsubscribeAllTopics("");
            }
//            for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().size(); i++) {
            //String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().get(i).getGatewayId();
            //字符串是自己按规则拼接的,里面注册主题时会解析字符串,只拿getGatewayId()值;
            //String topic = "/user/" + gatewayId+"/1";
            //进去住宅详情开始订阅主题
            MqttRecvClient.getInstance().checkAndsubscribeAllTopics("");
//            }
        } else if (eventBus.getTopic().equals(ConstantManage.homepage_title_tab_switch)) {
            //接收外部点击事件
            if (eventBus.getType().equals(HdlCommonLogic.HomepageTitleTabSwitch.powerstation.toString())) {
            if (eventBus.getType().equals(HomepageTitleTabSwitch.powerstation.toString())) {
                HdlLogLogic.print("正在点击【电站】");
            }
        }
@@ -218,6 +240,7 @@
                            }
                        }
                        nullDataUpdateUi(list);
                    }
                }, _mActivity, ShowErrorMode.YES);
@@ -247,10 +270,7 @@
        mPermissionsResultCallback = permissionsResultCallback;
        String[] s = new String[]{
                Manifest.permission.ACCESS_FINE_LOCATION,
                Manifest.permission.CAMERA,
        };
        String[] s = new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CAMERA,};
        String[] ary = PermissionUtils.checkPermission(_mActivity, s);
        if (ary.length > 0) {
            requestPermissions(ary, PermissionUtils.STATUS_SUCCESS);
@@ -288,4 +308,16 @@
    }
    /**
     * 没有电站列表的样式
     */
    private void nullDataUpdateUi(List<HouseIdBean> list) {
        if (list != null && list.size() > 0) {
            viewBinding.nullListTv.setVisibility(View.GONE);
        } else {
            viewBinding.nullListTv.setVisibility(View.VISIBLE);
        }
    }
}