| | |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.os.Looper; |
| | | import android.text.TextUtils; |
| | | import android.view.View; |
| | | |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | |
| | | import com.hdl.photovoltaic.ui.device.ScanActivity; |
| | | import com.hdl.photovoltaic.ui.newC.adapter.HouseListAdapter; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | | import com.hdl.photovoltaic.utils.PermissionUtils; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | import com.hdl.photovoltaic.widget.DelayedConfirmationCancelDialog; |
| | |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_FF000000)); |
| | | //初始化数据 |
| | | initData(); |
| | | //设置当前电站选中状态 |
| | | setSelectState(); |
| | | //初始化 |
| | | initView(); |
| | | //初始化界面监听器 |
| | |
| | | // downReadData(false); |
| | | } |
| | | |
| | | /** |
| | | * 初始化电站列表数据 |
| | | */ |
| | | private void initData() { |
| | | this.houseListBeanIDList = new ArrayList<>(); |
| | | this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList()); |
| | | setSelectState(); |
| | | // setSelectState(); |
| | | } |
| | | |
| | | private void initEvent() { |
| | |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> list) { |
| | | //发起删除电站指令 |
| | | deleteResidence(houseIdBean.getHomeId(), list); |
| | | deleteResidence(position, houseIdBean, list); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | //发起删除电站指令 |
| | | deleteResidence(houseIdBean.getHomeId(), null); |
| | | deleteResidence(position, houseIdBean, null); |
| | | } |
| | | }); |
| | | |
| | |
| | | viewBinding.addPowerStationTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | |
| | | // 未授权 如果应用程序没有所需的权限,则显示解释说明 |
| | | PermissionExplanationDialog.getInstance().showPortConflictPdDialog(_mActivity, getString(R.string.camera_storage_instructions), getString(R.string.camera_storage_purpose)); |
| | | PermissionUtils.requestPermissionsResultCallback(_mActivity, Manifest.permission.CAMERA, new PermissionUtils.PermissionState() { |
| | |
| | | if (houseListAdapter != null) { |
| | | //重新获取列表数据 |
| | | initData(); |
| | | refreshDetails(); |
| | | refreshDetails(""); |
| | | //更新电站选中状态 |
| | | setSelectState(); |
| | | //更新列表数据 |
| | |
| | | /** |
| | | * 删除电站 |
| | | * |
| | | * @param homeId 电站id |
| | | * @param list 逆变器列表 |
| | | * @param position 索引值 |
| | | * @param houseIdBean 电站id对象 |
| | | * @param list 逆变器列表 |
| | | */ |
| | | private void deleteResidence(String homeId, List<GatewayBean> list) { |
| | | private void deleteResidence(final int position, final HouseIdBean houseIdBean, List<GatewayBean> list) { |
| | | |
| | | //删除住宅 |
| | | HdlResidenceLogic.getInstance().delResidence(homeId, new CloudCallBeak<Boolean>() { |
| | | HdlResidenceLogic.getInstance().delResidence(houseIdBean.getHomeId(), new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | hideLoading(); |
| | | initializeInverter(list); //发起初始化指令给逆变器;(注意:前面已先解绑云端逆变器,mqtt通道已断开,初始化只能是本地发送(先搜索局域网逆变器列表,建立本地通讯通道)) |
| | | HdlResidenceLogic.getInstance().delHouseId(homeId);//删除电站缓存 |
| | | HdlResidenceLogic.getInstance().delHouseId(houseIdBean.getHomeId());//删除电站缓存 |
| | | initData();//初始化缓存数据 |
| | | refreshDetails(); |
| | | //更新电站选中状态 |
| | | setSelectState(); |
| | | houseListAdapter.setList(houseListBeanIDList); //更新列表数据 |
| | | refreshDetails(houseIdBean.getHomeId()); |
| | | setSelectState();//更新电站选中状态 |
| | | if (houseListAdapter != null) { |
| | | houseListAdapter.setList(houseListBeanIDList); //更新列表数据 |
| | | } |
| | | nullDataUpdateUi(houseListBeanIDList);//检测数据是否为空 |
| | | } |
| | | |
| | |
| | | * 通知uni更新数据 |
| | | * (在平台上删除C端当前住宅后,获取列表实收要通知uni那边更新界面卡片) |
| | | */ |
| | | private void refreshDetails() { |
| | | private void refreshDetails(final String homeId) { |
| | | try { |
| | | List<HouseIdBean> localHouseIdList = HdlResidenceLogic.getInstance().getHouseIdList(); |
| | | if (localHouseIdList.isEmpty()) { |
| | |
| | | uniCallBackBaseBean.setData(jsonObject); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | } else { |
| | | int select_home = -1; |
| | | for (int i = 0; i < localHouseIdList.size(); i++) { |
| | | if (localHouseIdList.get(i).getHomeId().equals(UserConfigManage.getInstance().getHomeId())) { |
| | | select_home = i; |
| | | break; |
| | | } |
| | | } |
| | | if (select_home == -1) { |
| | | //找不到默认第一个 |
| | | if (homeId.equals(UserConfigManage.getInstance().getHomeId()) || TextUtils.isEmpty(UserConfigManage.getInstance().getHomeId())) { |
| | | HouseIdBean houseIdBean = localHouseIdList.get(0); |
| | | HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true); |
| | | JsonObject jsonObject = new JsonObject(); |