| | |
| | | package com.hdl.photovoltaic.ui.newC; |
| | | |
| | | |
| | | import android.content.Intent; |
| | | import android.os.Bundle; |
| | | import android.view.View; |
| | | |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | |
| | | import com.google.gson.JsonObject; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.photovoltaic.HDLApp; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.CustomBaseActivity; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.databinding.ActivityPowerStationsListBinding; |
| | | import com.hdl.photovoltaic.enums.ShowErrorMode; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlResidenceLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.other.HdlUniLogic; |
| | | import com.hdl.photovoltaic.ui.CPowerStationActivity; |
| | | import com.hdl.photovoltaic.ui.StartActivity; |
| | | import com.hdl.photovoltaic.ui.adapter.LanguageAdapter; |
| | | import com.hdl.photovoltaic.ui.bean.HouseIdBean; |
| | | import com.hdl.photovoltaic.ui.newC.adapter.HouseListAdapter; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | setNotificationBarBackgroundColor(CustomColor.white); |
| | | setStatusBarTextColor(); |
| | | //初始化数据 |
| | | initData(); |
| | | //初始化 |
| | |
| | | private void initData() { |
| | | this.houseListBeanIDList = new ArrayList<>(); |
| | | this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList()); |
| | | setAllItemEdit(false); |
| | | } |
| | | |
| | | private void initEvent() { |
| | |
| | | }); |
| | | if (houseListAdapter != null) { |
| | | //电站移动位置按钮 |
| | | houseListAdapter.setNoOnclickListener(new HouseListAdapter.OnClickListener() { |
| | | houseListAdapter.setMoveOnclickListener(new HouseListAdapter.OnMoveClickListener() { |
| | | @Override |
| | | public void onMoveClick(int position, HouseIdBean houseIdBean) { |
| | | // HdlResidenceLogic.getInstance().delResidence(houseIdBean.getHomeId(), new CloudCallBeak<Boolean>() { |
| | | // @Override |
| | | // public void onSuccess(Boolean obj) { |
| | | //移动电站位置 |
| | | HdlResidenceLogic.getInstance().moveHouseId(houseIdBean.getHomeId()); |
| | | initData();//初始化缓存数据 |
| | | houseListAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | nullDataUpdateUi(houseListBeanIDList);//检测数据是否为空 |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onFailure(HDLException e) { |
| | | // HdlThreadLogic.toast(_mActivity, e); |
| | | // } |
| | | // }); |
| | | String frontHomeId = ""; |
| | | if (position > 0) { |
| | | frontHomeId = houseListBeanIDList.get(position - 1).getHomeId(); |
| | | } |
| | | HdlResidenceLogic.getInstance().moveResidence(houseIdBean.getHomeId(), frontHomeId, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | //移动电站位置 |
| | | HdlResidenceLogic.getInstance().moveHouseId(houseIdBean.getHomeId()); |
| | | initData();//初始化缓存数据 |
| | | houseListAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | nullDataUpdateUi(houseListBeanIDList);//检测数据是否为空 |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | }); |
| | | houseListAdapter.setOnItemClickListener(new HouseListAdapter.OnItemClickListener() { |
| | | @Override |
| | | public void onItemClick(int position, HouseIdBean houseBean) { |
| | | for (int i = 0; i < houseListBeanIDList.size(); i++) { |
| | | HouseIdBean houseIdBean = houseListBeanIDList.get(i); |
| | | houseIdBean.setState_select(false); |
| | | } |
| | | houseListBeanIDList.get(position).setState_select(true); |
| | | houseListAdapter.notifyDataSetChanged(); |
| | | if (UserConfigManage.getInstance().getHomeId().equals(houseBean.getHomeId())) { |
| | | //同一个不执行弹窗 |
| | | return; |
| | | } |
| | | houseSelectionDialog(houseBean); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | private void setAllItemEdit(boolean edit) { |
| | | for (int i = 0; i < houseListBeanIDList.size(); i++) { |
| | | houseListBeanIDList.get(i).setEdit(edit); |
| | | houseListBeanIDList.get(i).setMove(edit); |
| | | houseListBeanIDList.get(i).setDelIcon(false); |
| | | if (UserConfigManage.getInstance().getHomeId().equals(houseListBeanIDList.get(i).getHomeId())) { |
| | | this.houseListBeanIDList.get(i).setState_select(!edit); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | | * 二次确认提示框 |
| | | * |
| | | * @param houseIdBean 选中数据 |
| | | */ |
| | | private void houseSelectionDialog(HouseIdBean houseIdBean) { |
| | | ConfirmationCancelDialog dialog = new ConfirmationCancelDialog(this); |
| | | dialog.setTitle(getString(R.string.loading_title_tip)); |
| | | dialog.setContent(getString(R.string.switch_power_station).replace("%s", "\"" + houseIdBean.getHomeName() + "\"")); |
| | | dialog.show(); |
| | | dialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | UserConfigManage.getInstance().setHomeId(houseIdBean.getHomeId()); |
| | | UserConfigManage.getInstance().Save(); |
| | | dialog.dismiss(); |
| | | JsonObject jsonObject = new JsonObject(); |
| | | jsonObject.addProperty("homeId", houseIdBean.getHomeId()); |
| | | jsonObject.addProperty("homeName", houseIdBean.getHomeName()); |
| | | jsonObject.addProperty("powerStationStatus", houseIdBean.getPowerStationStatus()); |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_REFRESH_DETAILS); |
| | | uniCallBackBaseBean.setData(jsonObject); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | finish(); |
| | | |
| | | // //todo 逻辑: 这里可以指定关闭小程序详情,然后再重新打开详情界面; |
| | | // String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS_C |
| | | // + "?homeId=" + houseIdBean.getHomeId() |
| | | // + "&homeName=" + houseIdBean.getHomeName() |
| | | // + "&powerStationStatus=" + houseIdBean.getPowerStationStatus(); |
| | | // HdlUniLogic.getInstance().openUniMP(path, null); |
| | | |
| | | } |
| | | }); |
| | | dialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() { |
| | | @Override |
| | | public void Cancel() { |
| | | houseListAdapter.notifyDataSetChanged(); |
| | | dialog.dismiss(); |
| | | } |
| | | }); |
| | | } |
| | | } |