| | |
| | | |
| | | 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; |
| | |
| | | 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.newC.MessageCenterList; |
| | | import com.hdl.photovoltaic.ui.newC.PowerStationsListEdit; |
| | | 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; |
| | | |
| | |
| | | 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); |
| | | // } |
| | | // }); |
| | | // resumeTagStatus(); |
| | | // HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); |
| | | |
| | | Intent intent = new Intent(); |
| | | intent.setClass(_mActivity, MessageCenterList.class); |
| | | startActivity(intent); |
| | | |
| | | |
| | | } |
| | |
| | | @Override |
| | | public void onRefresh() { |
| | | downReadData(true); |
| | | HdlLogLogic.print("HouseListFragment下拉刷新", false); |
| | | } |
| | | }); |
| | | //进入电站详情,删除电站,移动电站位置 |
| | | houseInfoAdapter.setNoOnclickListener(new HouseInfoAdapter.OnclickListener() { |
| | | @Override |
| | | public void onClick(int position, HouseIdBean houseIdBean) { |
| | | resumeTagStatus(); |
| | | //点击住宅详情 |
| | | 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) { |
| | | if (position > 0) { |
| | | houseInfoAdapter.notifyItemMoved(position - 1, position); |
| | | } |
| | | // //移动电站位置 |
| | | // HdlResidenceLogic.getInstance().moveHouseId(houseIdBean.getHomeId()); |
| | | // initData();//初始化缓存数据 |
| | | // houseInfoAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | // nullDataUpdateUi(houseListBeanIDList);//检测数据是否为空 |
| | | // HdlResidenceLogic.getInstance().delResidence(houseIdBean.getHomeId(), 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) { |
| | | |
| | | 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(); |
| | | // } |
| | | // }); |
| | | 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();//初始化缓存数据 |
| | | setAllItemEdit(is_edit); |
| | | houseInfoAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | nullDataUpdateUi(houseListBeanIDList);//检测数据是否为空 |
| | | delayedConfirmationCancelDialog.dismiss(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | delayedConfirmationCancelDialog.setNoOnclickListener(new DelayedConfirmationCancelDialog.onNoOnclickListener() { |
| | | @Override |
| | | public void Cancel() { |
| | | delayedConfirmationCancelDialog.dismiss(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | }); |
| | |
| | | |
| | | } |
| | | } 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("正在点击【电站】"); |
| | | resumeTagStatus(); |
| | | initData();//初始化缓存数据 |
| | | setAllItemEdit(false); |
| | | houseInfoAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 恢复到未编辑电站状态 |
| | | */ |
| | | private void resumeTagStatus() { |
| | | is_edit = false; //还原编辑标记 |
| | | viewBinding.toolbarTopFragmentHouseListRl.topBackBtn.setVisibility(View.GONE);//隐藏后退图标 |
| | | } |
| | | |
| | | /** |
| | | * 申请权限 |
| | | */ |
| | | private void requestPermissions(PermissionsResultCallback permissionsResultCallback) { |
| | |
| | | * 没有电站列表的样式 |
| | | */ |
| | | 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); |
| | | } |
| | | |
| | | |