| | |
| | | import com.hdl.photovoltaic.databinding.FragmentHouseListBinding; |
| | | import com.hdl.photovoltaic.base.CustomBaseFragment; |
| | | import com.hdl.photovoltaic.enums.DebugStatus; |
| | | import com.hdl.photovoltaic.enums.DebugType; |
| | | import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch; |
| | | import com.hdl.photovoltaic.enums.LowerTagType; |
| | | import com.hdl.photovoltaic.enums.PowerStationStatus; |
| | | import com.hdl.photovoltaic.enums.ProjectOperation; |
| | | import com.hdl.photovoltaic.enums.ShowErrorMode; |
| | | import com.hdl.photovoltaic.enums.SortType; |
| | | import com.hdl.photovoltaic.enums.SortValue; |
| | |
| | | import com.hdl.photovoltaic.utils.GPSManagerUtils; |
| | | import com.hdl.photovoltaic.utils.PermissionUtils; |
| | | import com.hdl.photovoltaic.utils.URLEncodingUtils; |
| | | import com.hdl.photovoltaic.widget.AddPowerStationDialog; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | import com.hdl.photovoltaic.widget.DefaultFilteringDialog; |
| | | import com.hdl.photovoltaic.widget.DelayedConfirmationCancelDialog; |
| | | import com.hdl.photovoltaic.widget.adapter.PowerStationDialogAdapter; |
| | | import com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout; |
| | | import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder; |
| | | import com.hdl.sdk.link.common.exception.HDLLinkException; |
| | |
| | | viewBinding.addIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | |
| | | requestPermissions(new OnCallBeak() { |
| | | AddPowerStationDialog addPowerStationDialog = new AddPowerStationDialog(_mActivity); |
| | | addPowerStationDialog.show(); |
| | | addPowerStationDialog.setCanceledOnTouchOutside(true); |
| | | addPowerStationDialog.setItemOnclickListener(new PowerStationDialogAdapter.OnclickListener() { |
| | | @Override |
| | | public void onClickCallBeak() { |
| | | // UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1); |
| | | // HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); |
| | | public void onClick(int position, String str) { |
| | | addPowerStationDialog.dismiss(); |
| | | UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1); |
| | | if (_mActivity.getString(R.string.simple_debugging).equals(str)) { |
| | | HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION_SIMPLE, null); |
| | | } else { |
| | | 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); |
| | | // } |
| | | // }); |
| | | } |
| | | }); |
| | | |
| | |
| | | |
| | | @Override |
| | | public void onDelClick(int position, HouseIdBean houseIdBean) { |
| | | |
| | | final boolean isWaitDelivered = houseIdBean.getDebugStatus().equals(DebugStatus.WAIT_DELIVERED); |
| | | DelayedConfirmationCancelDialog delayedConfirmationCancelDialog = new DelayedConfirmationCancelDialog(_mActivity); |
| | | delayedConfirmationCancelDialog.show(); |
| | | delayedConfirmationCancelDialog.isHideTitle(true); |
| | | String homeName = "\"" + houseIdBean.getHomeName() + "\""; |
| | | delayedConfirmationCancelDialog.setContent(getString(R.string.delete_power_station).replace("%s", homeName)); |
| | | |
| | | delayedConfirmationCancelDialog.startCountdown(4); |
| | | if (isWaitDelivered) { |
| | | //"是否将电站的调试状态回退到调试中" |
| | | delayedConfirmationCancelDialog.setContent(getString(R.string.debug_status_rollback).replace("%s", homeName)); |
| | | } else { |
| | | delayedConfirmationCancelDialog.startCountdown(4); |
| | | delayedConfirmationCancelDialog.setContent(getString(R.string.delete_power_station).replace("%s", homeName)); |
| | | } |
| | | delayedConfirmationCancelDialog.setYesOnclickListener(new DelayedConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | delayedConfirmationCancelDialog.dismiss(); |
| | | showLoading(getString(R.string.deleting_please_wait)); |
| | | HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(houseIdBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> list) { |
| | | //发起删除电站指令 |
| | | deleteResidence(houseIdBean.getHomeId(), list); |
| | | if (isWaitDelivered) { |
| | | showLoading(); |
| | | HdlResidenceLogic.getInstance().setUpdateProjectDebugStatus(houseIdBean.getHomeId(), houseIdBean.getCommunityId(), houseIdBean.getFlowRecordContent(), ProjectOperation.DEBUGGING_AGAIN.toString(), new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean list) { |
| | | hideLoading(); |
| | | if (houseInfoAdapter != null) { |
| | | houseIdBean.setDebugStatus(DebugStatus.Debugging); |
| | | HdlResidenceLogic.getInstance().updateHouseIdBean(houseIdBean); |
| | | initData(); |
| | | //更新UI |
| | | houseInfoAdapter.notifyItemChanged(position); |
| | | } |
| | | } |
| | | |
| | | } |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | hideLoading(); |
| | | } |
| | | }); |
| | | } else { |
| | | showLoading(getString(R.string.deleting_please_wait)); |
| | | HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(houseIdBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> list) { |
| | | //发起删除电站指令 |
| | | deleteResidence(position, houseIdBean, list); |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | //发起删除电站指令 |
| | | deleteResidence(houseIdBean.getHomeId(), null); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // //删除住宅 |
| | | // HdlResidenceLogic.getInstance().delResidence(houseIdBean.getHomeId(), new CloudCallBeak<Boolean>() { |
| | | // @Override |
| | | // public void onSuccess(Boolean obj) { |
| | | // HdlResidenceLogic.getInstance().delHouseId(houseIdBean.getHomeId()); |
| | | // initData();//初始化缓存数据 |
| | | // houseInfoAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | // nullDataUpdateUi(houseListBeanIDList);//检测数据是否为空 |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onFailure(HDLException e) { |
| | | // HdlThreadLogic.toast(_mActivity, e); |
| | | // } |
| | | // }); |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | //发起删除电站指令 |
| | | deleteResidence(position, houseIdBean, null); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | delayedConfirmationCancelDialog.setNoOnclickListener(new DelayedConfirmationCancelDialog.onNoOnclickListener() { |
| | |
| | | deviceInfoAdapter.setOnclickListener(new DeviceInfoAdapter.OnClickListener() { |
| | | @Override |
| | | public void onClick(int position, CloudInverterDeviceBean deviceBean) { |
| | | if (!deviceBean.isActivate()) { |
| | | HdlThreadLogic.toast(_mActivity, getString(R.string.device_not_activated)); |
| | | return; |
| | | } |
| | | // GatewayBean gatewayBean = new GatewayBean(); |
| | | // gatewayBean.setCategorySecondName(deviceBean.getCategorySecondName()); |
| | | // gatewayBean.setDevice_mac(deviceBean.getOsn()); |
| | |
| | | viewBinding.fragmentHouseSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity)); |
| | | viewBinding.fragmentHouseSrlListRc.setAdapter(houseInfoAdapter); |
| | | houseInfoAdapter.setList(this.houseListBeanIDList, powerStationStatusValue); |
| | | |
| | | //设备标签 |
| | | deviceInfoAdapter = new DeviceInfoAdapter(_mActivity); |
| | | viewBinding.fragmentDeviceSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity)); |
| | |
| | | /** |
| | | * 删除电站 |
| | | * |
| | | * @param homeId 电站id |
| | | * @param list 逆变器列表 |
| | | * @param position 位置 |
| | | * @param houseIdBean 电站id对象 |
| | | * @param list 逆变器列表 |
| | | */ |
| | | private void deleteResidence(String homeId, List<GatewayBean> list) { |
| | | private void deleteResidence(int position, 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);//删除电站缓存 |
| | | if (houseIdBean.getDebugType().equals(DebugType.NORMAL)) { |
| | | initializeInverter(list); //发起初始化指令给逆变器;(注意:前面已先解绑云端逆变器,mqtt通道已断开,初始化只能是本地发送(先搜索局域网逆变器列表,建立本地通讯通道)) |
| | | } |
| | | HdlResidenceLogic.getInstance().delHouseId(houseIdBean.getHomeId());//删除电站缓存 |
| | | initData();//初始化缓存数据 |
| | | houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//重新刷新列表 |
| | | if (houseInfoAdapter != null) { |
| | | // houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//重新刷新列表 |
| | | houseInfoAdapter.notifyItemRemoved(position);//只刷新当前的位置 |
| | | } |
| | | getStatusOverview();//删除成功后刷新电站状态概览 |
| | | nullDataUpdateUi();//检测数据是否为空 |
| | | } |
| | |
| | | if (ary.length > 0) { |
| | | this.requestPermissions(ary, PermissionUtils.STATUS_SUCCESS); |
| | | } else { |
| | | |
| | | UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1); |
| | | HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); |
| | | locationUpdates(); |
| | | |
| | | |
| | | AddPowerStationDialog addPowerStationDialog = new AddPowerStationDialog(_mActivity); |
| | | addPowerStationDialog.show(); |
| | | addPowerStationDialog.setCanceledOnTouchOutside(true); |
| | | addPowerStationDialog.setItemOnclickListener(new PowerStationDialogAdapter.OnclickListener() { |
| | | @Override |
| | | public void onClick(int position, String str) { |
| | | addPowerStationDialog.dismiss(); |
| | | // UserConfigManage.getInstance().setCurrentAppLanguage(itemData.getLanguage()); |
| | | // UserConfigManage.getInstance().Save(); |
| | | UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1); |
| | | if (_mActivity.getString(R.string.simple_debugging).equals(str)) { |
| | | HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION_SIMPLE, null); |
| | | } else { |
| | | HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); |
| | | } |
| | | locationUpdates(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |