From 788c70114287306db20e9a4539018d6e32fb5cb7 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期五, 19 四月 2024 10:10:10 +0800
Subject: [PATCH] Merge branch 'wjc_new' into develop_new
---
app/src/main/java/com/hdl/photovoltaic/ui/newC/PowerStationsListEdit.java | 123 +++++++++++++++++++++++++++++++++++-----
1 files changed, 106 insertions(+), 17 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/newC/PowerStationsListEdit.java b/app/src/main/java/com/hdl/photovoltaic/ui/newC/PowerStationsListEdit.java
index 7828cfc..c39a689 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/newC/PowerStationsListEdit.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/newC/PowerStationsListEdit.java
@@ -7,17 +7,22 @@
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.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.bean.HouseIdBean;
import com.hdl.photovoltaic.ui.newC.adapter.HouseListAdapter;
+import com.hdl.photovoltaic.uni.HDLUniMP;
+import com.hdl.photovoltaic.widget.ConfirmationCancelDialog;
import java.util.ArrayList;
import java.util.List;
@@ -42,6 +47,8 @@
@Override
public void onBindView(Bundle savedInstanceState) {
+ setNotificationBarBackgroundColor(CustomColor.white);
+ setStatusBarTextColor();
//鍒濆鍖栨暟鎹�
initData();
//鍒濆鍖�
@@ -53,6 +60,7 @@
private void initData() {
this.houseListBeanIDList = new ArrayList<>();
this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList());
+ setAllItemEdit(false);
}
private void initEvent() {
@@ -97,26 +105,53 @@
});
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);
-// }
-// });
+ if (position == 0) {
+ HdlThreadLogic.toast(_mActivity, getString(R.string.already_the_first_one));
+ return;
+ }
+ String frontHomeId = "";
+ if (position > 1) {
+ frontHomeId = houseListBeanIDList.get(position - 2).getHomeId();
+ }
+ HdlResidenceLogic.getInstance().moveResidence(houseIdBean.getHomeId(), frontHomeId, new CloudCallBeak<Boolean>() {
+ @Override
+ public void onSuccess(Boolean obj) {
+ //绉诲姩鐢电珯浣嶇疆
+ HdlResidenceLogic.getInstance().moveHouseId(houseIdBean.getHomeId());
+ initData();//鍒濆鍖栫紦瀛樻暟鎹�
+ setAllItemEdit(is_edit);
+ 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);
+ }
+ });
+
}
}
@@ -193,7 +228,11 @@
*/
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);
+ }
}
}
@@ -203,4 +242,54 @@
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() {
+ HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
+ 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() {
+ //鍙栨秷涔嬪悗杩樺師涔嬪墠鐘舵��
+ for (int i = 0; i < houseListBeanIDList.size(); i++) {
+ HouseIdBean houseIdBean = houseListBeanIDList.get(i);
+ houseIdBean.setState_select(false);
+ if (UserConfigManage.getInstance().getHomeId().equals(houseIdBean.getHomeId())) {
+ houseIdBean.setState_select(true);
+ }
+ }
+ houseListAdapter.notifyDataSetChanged();
+ dialog.dismiss();
+ }
+ });
+ }
}
\ No newline at end of file
--
Gitblit v1.8.0