| | |
| | | import com.hdl.photovoltaic.ui.bean.HouseIdBean; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.utils.PermissionUtils; |
| | | import com.hdl.photovoltaic.widget.DelayedConfirmationCancelDialog; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient; |
| | | |
| | |
| | | * (住宅)电站列表-界面 |
| | | */ |
| | | public class HouseListFragment extends CustomBaseFragment { |
| | | private boolean is_edit = false; |
| | | private FragmentHouseListBinding viewBinding; |
| | | private HouseInfoAdapter houseInfoAdapter; |
| | | private CameraManager manager; |
| | |
| | | |
| | | private void initEvent() { |
| | | |
| | | viewBinding.toolbarTopFragmentHouseListRl.topBackBtn.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (is_edit) { |
| | | is_edit = false; |
| | | } |
| | | viewBinding.toolbarTopFragmentHouseListRl.topBackBtn.setVisibility(View.GONE); |
| | | initData();//初始化缓存数据 |
| | | setAllItemEdit(false); |
| | | houseInfoAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | } |
| | | }); |
| | | |
| | | //添加电站 |
| | | viewBinding.toolbarTopFragmentHouseListRl.topMoreIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); |
| | | // requestPermissions(new PermissionsResultCallback() { |
| | | // @Override |
| | | // public void succeed() { |
| | | //// Intent intent = new Intent(); |
| | | //// intent.setClass(_mActivity, FastScanActivity.class); |
| | | //// startActivity(intent); |
| | | //// // 打开小程序页面 |
| | | // HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void failing() { |
| | | // HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); |
| | | // } |
| | | // }); |
| | | |
| | | |
| | | } |
| | | }); |
| | |
| | | @Override |
| | | public void onRefresh() { |
| | | downReadData(true); |
| | | HdlLogLogic.print("HouseListFragment下拉刷新", 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(); |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS + "?homeId=" + houseIdBean.getHomeId() + "&homeName=" + houseIdBean.getHomeName() + "&powerStationStatus=" + houseIdBean.getPowerStationStatus(); |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onMoveClick(int position, HouseIdBean houseIdBean) { |
| | | String frontHomeId = ""; |
| | | if (position > 0) { |
| | | houseInfoAdapter.notifyItemMoved(position - 1, position); |
| | | frontHomeId = houseListBeanIDList.get(position - 1).getHomeId(); |
| | | } |
| | | // //移动电站位置 |
| | | // HdlResidenceLogic.getInstance().moveHouseId(houseIdBean.getHomeId()); |
| | | // initData();//初始化缓存数据 |
| | | // houseInfoAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | // nullDataUpdateUi(houseListBeanIDList);//检测数据是否为空 |
| | | HdlResidenceLogic.getInstance().moveResidence(houseIdBean.getHomeId(), frontHomeId, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | //移动电站位置 |
| | | HdlResidenceLogic.getInstance().moveHouseId(houseIdBean.getHomeId()); |
| | | initData();//初始化缓存数据 |
| | | houseInfoAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | nullDataUpdateUi(houseListBeanIDList);//检测数据是否为空 |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onDelClick(int position, HouseIdBean houseIdBean) { |
| | | DelayedConfirmationCancelDialog delayedConfirmationCancelDialog = new DelayedConfirmationCancelDialog(_mActivity); |
| | | delayedConfirmationCancelDialog.setTitleContent(getString(R.string.loading_title_tip)); |
| | | String homeName = "\"" + houseIdBean.getHomeName() + "\""; |
| | | delayedConfirmationCancelDialog.setContent(getString(R.string.delete_power_station).replace("XX", homeName)); |
| | | delayedConfirmationCancelDialog.show(); |
| | | delayedConfirmationCancelDialog.startCountdown(3); |
| | | delayedConfirmationCancelDialog.setYesOnclickListener(new DelayedConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | //删除住宅 |
| | | 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);//检测数据是否为空 |
| | | delayedConfirmationCancelDialog.dismiss(); |
| | | } |
| | | |
| | | HdlResidenceLogic.getInstance().delHouseId(houseIdBean.getHomeId()); |
| | | initData();//初始化缓存数据 |
| | | houseInfoAdapter.notifyItemRemoved(position); |
| | | |
| | | // DelayedConfirmationCancelDialog delayedConfirmationCancelDialog = new DelayedConfirmationCancelDialog(_mActivity); |
| | | // delayedConfirmationCancelDialog.setTitle(R.string.loading_title_tip); |
| | | // delayedConfirmationCancelDialog.setContent("是否确认删除电站?"); |
| | | // delayedConfirmationCancelDialog.show(); |
| | | // delayedConfirmationCancelDialog.startCountdown(3); |
| | | // delayedConfirmationCancelDialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | // @Override |
| | | // public void Confirm() { |
| | | // //删除住宅 |
| | | // HdlResidenceLogic.getInstance().delResidence(houseIdBean.getHomeId(), new CloudCallBeak<Boolean>() { |
| | | // @Override |
| | | // public void onSuccess(Boolean obj) { |
| | | // HdlResidenceLogic.getInstance().delHouseId(houseIdBean.getHomeId()); |
| | | // initData();//初始化缓存数据 |
| | | // setAllItemEdit(is_edit); |
| | | // houseInfoAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | // nullDataUpdateUi(houseListBeanIDList);//检测数据是否为空 |
| | | // delayedConfirmationCancelDialog.dismiss(); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onFailure(HDLException e) { |
| | | // HdlThreadLogic.toast(_mActivity, e); |
| | | // } |
| | | // }); |
| | | // } |
| | | // }); |
| | | // delayedConfirmationCancelDialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() { |
| | | // @Override |
| | | // public void Cancel() { |
| | | // delayedConfirmationCancelDialog.dismiss(); |
| | | // } |
| | | // }); |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | delayedConfirmationCancelDialog.setNoOnclickListener(new DelayedConfirmationCancelDialog.onNoOnclickListener() { |
| | | @Override |
| | | public void Cancel() { |
| | | delayedConfirmationCancelDialog.dismiss(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | }); |
| | |
| | | viewBinding.toolbarTopFragmentHouseListRl.topEditIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (is_edit) { |
| | | //防止多次点击 |
| | | return; |
| | | } |
| | | is_edit = true; |
| | | viewBinding.toolbarTopFragmentHouseListRl.topBackBtn.setVisibility(View.VISIBLE); |
| | | if (houseInfoAdapter == null) { |
| | | return; |
| | | } |
| | | initData();//初始化缓存数据 |
| | | setAllItemEdit(true); |
| | | houseInfoAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | startActivity(HouseListEditActivity.class); |
| | | } |
| | | }); |
| | | } |
| | |
| | | |
| | | } |
| | | } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE.equals(eventBus.getType())) { |
| | | |
| | | //uin关闭住宅详情界面通知 |
| | | if (MqttRecvClient.getInstance() != null) { |
| | | MqttRecvClient.getInstance().removeAllTopic(); |
| | |
| | | //接收外部点击事件 |
| | | if (eventBus.getType().equals(HomepageTitleTabSwitch.powerstation.toString())) { |
| | | HdlLogLogic.print("正在点击【电站】"); |
| | | initData();//初始化缓存数据 |
| | | houseInfoAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置全部缓存数据编辑状态 |
| | | * |
| | | * @param edit true表示在编辑状态 |
| | | */ |
| | | private void setAllItemEdit(boolean edit) { |
| | | for (int i = 0; i < houseListBeanIDList.size(); i++) { |
| | | houseListBeanIDList.get(i).setEdit(edit); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 刷新UI |
| | |
| | | HdlResidenceLogic.getInstance().setHouseIdList(list); |
| | | if (houseInfoAdapter != null) { |
| | | initData(); |
| | | setAllItemEdit(is_edit); |
| | | //更新UI |
| | | houseInfoAdapter.setList(houseListBeanIDList); |
| | | } |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 申请权限 |
| | |
| | | * 没有电站列表的样式 |
| | | */ |
| | | private void nullDataUpdateUi(List<HouseIdBean> list) { |
| | | HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, |
| | | viewBinding.nullDataIc.getRoot(), |
| | | viewBinding.nullDataIc.nullDataGifAnimationIv, |
| | | viewBinding.nullDataIc.nullDataTv, getString(R.string.my_power_station_data_null), list != null && list.size() > 0); |
| | | HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.nullDataIc.getRoot(), viewBinding.nullDataIc.nullDataGifAnimationIv, viewBinding.nullDataIc.nullDataTv, getString(R.string.my_power_station_data_null), list != null && list.size() > 0); |
| | | } |
| | | |
| | | |