From bfc932a6348457a022269ea993117c41cc051fe5 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期五, 29 八月 2025 17:47:35 +0800
Subject: [PATCH] 2025年08月29日17:47:33
---
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java | 916 +++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 636 insertions(+), 280 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
index 22a168f..19c3b8f 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
@@ -1,51 +1,74 @@
package com.hdl.photovoltaic.ui.powerstation;
+import android.Manifest;
+import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.location.LocationManager;
+import android.os.AsyncTask;
import android.os.Bundle;
+import android.provider.Settings;
+import android.text.TextUtils;
import android.view.View;
+import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.google.gson.Gson;
import com.hdl.linkpm.sdk.core.exception.HDLException;
+import com.hdl.photovoltaic.HDLApp;
import com.hdl.photovoltaic.R;
import com.hdl.photovoltaic.bean.PageNumberObject;
import com.hdl.photovoltaic.config.ConstantManage;
import com.hdl.photovoltaic.config.UserConfigManage;
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.listener.CloudCallBeak;
import com.hdl.photovoltaic.listener.LinkCallBack;
+import com.hdl.photovoltaic.listener.OnCallBeak;
import com.hdl.photovoltaic.other.HdlCommonLogic;
import com.hdl.photovoltaic.other.HdlDeviceLogic;
+import com.hdl.photovoltaic.other.HdlDialogLogic;
import com.hdl.photovoltaic.other.HdlLogLogic;
import com.hdl.photovoltaic.other.HdlResidenceLogic;
import com.hdl.photovoltaic.other.HdlThreadLogic;
import com.hdl.photovoltaic.other.HdlUniLogic;
import com.hdl.photovoltaic.ui.adapter.DeviceInfoAdapter;
import com.hdl.photovoltaic.ui.adapter.HouseInfoAdapter;
-import com.hdl.photovoltaic.ui.bean.DeviceBean;
+import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean;
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
import com.hdl.photovoltaic.ui.bean.StatusOverviewBean;
import com.hdl.photovoltaic.uni.HDLUniMP;
+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;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
+import com.hdl.sdk.link.core.config.HDLLinkConfig;
import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient;
+import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -58,15 +81,15 @@
* 鐢电珯鍜岃澶�-鐣岄潰
*/
public class HouseAndDeviceFragment extends CustomBaseFragment {
+
+ private boolean isReadData = false;
private FragmentHouseListBinding viewBinding;
private HouseInfoAdapter houseInfoAdapter;
private DeviceInfoAdapter deviceInfoAdapter;
private List<HouseIdBean> houseListBeanIDList;
- private List<DeviceBean> deviceInfoList;
-
-
+ private List<CloudInverterDeviceBean> deviceInfoList;
private int currentHouseListPage = 0; // 褰撳墠鐢电珯鍒楄〃椤电爜
private int currentHouseListTotal = 0; // 鐢电珯鍒楄〃鎬婚〉鐮�
private boolean isHouseLoadingMore = false; // 鏍囪鐢电珯鍒楄〃姝e湪鍔犺浇鏇村鏁版嵁
@@ -81,11 +104,22 @@
private String value = SortValue.all;//descending:闄嶅簭,ascending:鍗囧簭
private String installedCapacityMinValue = "";//鏈�灏忕粍涓插閲�(瑁呮満瀹归噺)
private String installedCapacityMaxValue = "";//鏈�澶х粍涓插閲�(瑁呮満瀹归噺)
- private String gridTypeValue = "";//骞剁綉鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,FULL_GRID:骞剁綉,OFFLINE:绂荤綉)
- private String powerStationStatusValue = "";//鐢电珯鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,1:姝e父(杩愯),2:绂荤嚎,3:寰呮帴鍏�,4:鏁呴殰)
+ private String screeningConditionStatus = DebugStatus.All;//绛涢�夋潯浠剁姸鎬�
+ private String powerStationStatusValue = PowerStationStatus.All;//鐢电珯鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,1:姝e父(杩愯),2:绂荤嚎,3:寰呮帴鍏�,4:鏁呴殰)
- private final long pageSize = 20;//椤垫暟
+ private final long pageSize = 100;//涓�椤靛ぇ灏�
+ /**
+ * 杩樺師鏉′欢鐨勫垵濮嬪寲鐘舵��
+ */
+ private void initializationState() {
+ key = SortValue.all;
+ value = SortValue.all;
+ installedCapacityMinValue = "";
+ installedCapacityMaxValue = "";
+ screeningConditionStatus = DebugStatus.All;
+ powerStationStatusValue = PowerStationStatus.All;
+ }
@Override
public Object getContentView() {
@@ -95,8 +129,6 @@
@Override
public void onBindView(Bundle savedInstanceState) {
- //鏀惧湪杩欓噷涔熷锛岃繖閲屽彧鏄鍒涘缓涓�娆�
-// loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
// getStatusOverview();
initData();
//鍒濆鍖�
@@ -115,13 +147,11 @@
return;
}
isClickPowerStationLabel = true;
- viewBinding.powerStationLabel.setTextAppearance(R.style.Text20Style);
- viewBinding.deviceLabel.setTextAppearance(R.style.Text16Style);
- viewBinding.editIv.setVisibility(View.VISIBLE);//缂栬緫鍥炬爣闅愯棌
- viewBinding.addIv.setVisibility(View.VISIBLE);//娣诲姞鍥炬爣闅愯棌
- viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);//鐢电珯鏍囩銆愮埗瀹瑰櫒銆戞樉绀�
- viewBinding.deviceLabelParent.setVisibility(View.GONE);//璁惧鏍囩銆愮埗瀹瑰櫒銆戦殣钘�
- loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+ selectedTitleLabelStyle();
+ initializationState();
+ getStatusOverview();
+ loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
+
}
});
//璁惧鏍囩
@@ -132,45 +162,60 @@
return;
}
isClickPowerStationLabel = false;
- viewBinding.deviceLabel.setTextAppearance(R.style.Text20Style);
- viewBinding.powerStationLabel.setTextAppearance(R.style.Text16Style);
- viewBinding.editIv.setVisibility(View.GONE);//缂栬緫鍥炬爣闅愯棌
- viewBinding.addIv.setVisibility(View.GONE);//娣诲姞鍥炬爣闅愯棌
- viewBinding.powerStationLabelParent.setVisibility(View.GONE);//鐢电珯鏍囩銆愮埗瀹瑰櫒銆戦殣钘�
- viewBinding.deviceLabelParent.setVisibility(View.VISIBLE);//璁惧鏍囩銆愮埗瀹瑰櫒銆戞樉绀�
+ selectedTitleLabelStyle();
loadNextPageDeviceList(true, 1, true);
}
});
//鍏ㄩ儴
- viewBinding.powerStationAllIl.parentLl.setOnClickListener(new View.OnClickListener() {
+ viewBinding.allLl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- selectedStationStyle(viewBinding.powerStationAllIl.parentLl, viewBinding.powerStationAllIl.stationTotalTv, viewBinding.powerStationAllIl.stationTitleTv, true);
- loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+ if (powerStationStatusValue.equals(PowerStationStatus.All)) {
+ return;
+ }
+ powerStationStatusValue = PowerStationStatus.All;
+ stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv);
+ getStatusOverview();
+ loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
}
});
//鏁呴殰
- viewBinding.powerStationFaultsIl.parentLl.setOnClickListener(new View.OnClickListener() {
+ viewBinding.faultsLl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- selectedStationStyle(viewBinding.powerStationFaultsIl.parentLl, viewBinding.powerStationFaultsIl.stationTotalTv, viewBinding.powerStationFaultsIl.stationTitleTv, true);
- loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+ if (powerStationStatusValue.equals(PowerStationStatus.malfunction)) {
+ return;
+ }
+ powerStationStatusValue = PowerStationStatus.malfunction;
+ stationStatusStyle(viewBinding.faultsLl, viewBinding.faultsDesTv);
+ getStatusOverview();
+ loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
}
});
//绂荤嚎
- viewBinding.hpowerStationOfflineIl.parentLl.setOnClickListener(new View.OnClickListener() {
+ viewBinding.offlineLl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- selectedStationStyle(viewBinding.hpowerStationOfflineIl.parentLl, viewBinding.hpowerStationOfflineIl.stationTotalTv, viewBinding.hpowerStationOfflineIl.stationTitleTv, true);
- loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+ if (powerStationStatusValue.equals(PowerStationStatus.off)) {
+ return;
+ }
+ powerStationStatusValue = PowerStationStatus.off;
+ stationStatusStyle(viewBinding.offlineLl, viewBinding.offlineDesTv);
+ getStatusOverview();
+ loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
}
});
//寰呮帴鍏�
- viewBinding.powerStationConnectedIl.parentLl.setOnClickListener(new View.OnClickListener() {
+ viewBinding.connectedLl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- selectedStationStyle(viewBinding.powerStationConnectedIl.parentLl, viewBinding.powerStationConnectedIl.stationTotalTv, viewBinding.powerStationConnectedIl.stationTitleTv, true);
- loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+ if (powerStationStatusValue.equals(PowerStationStatus.connecting)) {
+ return;
+ }
+ powerStationStatusValue = PowerStationStatus.connecting;
+ stationStatusStyle(viewBinding.connectedLl, viewBinding.connectedDesTv);
+ getStatusOverview();
+ loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
}
});
@@ -178,7 +223,28 @@
viewBinding.addIv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+ 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().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);
+// }
+// });
+ }
+ });
}
});
@@ -197,49 +263,17 @@
public void onClick(View v) {
DefaultFilteringDialog defaultFilteringDialog = new DefaultFilteringDialog(_mActivity);
defaultFilteringDialog.show();
- defaultFilteringDialog.initState(installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue);
+ defaultFilteringDialog.initState(installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus);
defaultFilteringDialog.setOnClickListener(new DefaultFilteringDialog.OnClickListener() {
@Override
public void confirm(String min, String max, String state) {
installedCapacityMinValue = min;//鏈�灏忕粍涓插閲�(瑁呮満瀹归噺)
installedCapacityMaxValue = max;//鏈�澶х粍涓插閲�(瑁呮満瀹归噺)
- gridTypeValue = state;//骞剁綉鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,FULL_GRID:骞剁綉,OFFLINE:绂荤綉)
- loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+ screeningConditionStatus = state;//璋冭瘯鐘舵��(鍏ㄩ儴;璋冭瘯涓�;璋冭瘯瀹屾垚;宸蹭氦浠�;鎺堟潈璋冭瘯)
+ getStatusOverview();
+ loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
}
});
- }
- });
-
- //鐢电珯璁剧疆涓嬫媺绠ご棰滆壊
- viewBinding.fragmentHouseSrl.setColorSchemeResources(R.color.text_FF245EC3);
- //鐢电珯涓嬫媺璇诲彇
- viewBinding.fragmentHouseSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
- @Override
- public void onRefresh() {
- viewBinding.fragmentHouseSrl.setRefreshing(false);
- loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
- }
- });
- //鐢电珯涓婃媺璇诲彇
- viewBinding.fragmentHouseSrlListRc.addOnScrollListener(new RecyclerView.OnScrollListener() {
- @Override
- public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
-// super.onScrolled(recyclerView, dx, dy);
-
- LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
- if (layoutManager == null) {
- return;
- }
- int visibleItemCount = layoutManager.getChildCount();
- int totalItemCount = layoutManager.getItemCount();
- int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
- if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) {
- if (!isHouseLoadingMore) {
- // 婊戝姩鍒颁簡搴曢儴锛屾墽琛岀浉搴旂殑鎿嶄綔
- HdlLogLogic.print("---婊戝姩鍒颁簡搴曢儴");
- loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, ++currentHouseListPage, false);
- }
- }
}
});
//鐢电珯璇︽儏杩涘叆,鍒犻櫎鐢电珯,绉诲姩鐢电珯浣嶇疆
@@ -247,11 +281,11 @@
@Override
public void onClick(int position, HouseIdBean houseIdBean) {
//鐐瑰嚮浣忓畢璇︽儏
- HdlLogLogic.print("鐐瑰嚮浣忓畢璇︽儏---" + new Gson().toJson(houseIdBean), false);
- HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
+ UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(0);
+ HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true);
String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS + "?homeId=" + houseIdBean.getHomeId() + "&homeName=" + houseIdBean.getHomeName() + "&powerStationStatus=" + houseIdBean.getPowerStationStatus();
HdlUniLogic.getInstance().openUniMP(path, null);
-
+ HdlLogLogic.print("鐐瑰嚮浣忓畢璇︽儏---" + new Gson().toJson(houseIdBean), false);
}
@Override
@@ -270,7 +304,7 @@
//绉诲姩鐢电珯浣嶇疆
HdlResidenceLogic.getInstance().moveHouseId(houseIdBean.getHomeId());
initData();//鍒濆鍖栫紦瀛樻暟鎹�
- houseInfoAdapter.setList(houseListBeanIDList);//閲嶆柊鍒锋柊鍒楄〃
+ houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//閲嶆柊鍒锋柊鍒楄〃
nullDataUpdateUi();//妫�娴嬫暟鎹槸鍚︿负绌�
}
@@ -285,48 +319,69 @@
@Override
public void onDelClick(int position, HouseIdBean houseIdBean) {
-
+ final boolean isWaitDelivered = houseIdBean.getDebugStatus().equals(DebugStatus.WAIT_DELIVERED);
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("%s", homeName));
delayedConfirmationCancelDialog.show();
- delayedConfirmationCancelDialog.startCountdown(4);
+ delayedConfirmationCancelDialog.isHideTitle(true);
+ String homeName = "\"" + houseIdBean.getHomeName() + "\"";
+ 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();
+ String flowRecordContent = UserConfigManage.getInstance().isZh() ? "鏂扮壒閿愯兘app鍙戣捣鐢电珯閲嶆柊璋冭瘯" : "The Xenterra app initiates the re-commissioning of the power station";
+ HdlResidenceLogic.getInstance().setUpdateProjectDebugStatus(houseIdBean.getHomeId(), houseIdBean.getCommunityId(), flowRecordContent, 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();
+ if (houseInfoAdapter != null) {
+ houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//閲嶆柊鍒锋柊鍒楄〃
+ }
+ //鏇存柊UI
+// houseInfoAdapter.notifyItemChanged(position);
+ }
+ }
+ @Override
+ public void onFailure(HDLException e) {
+ hideLoading();
+ }
+ });
+ } else {
+ showLoading(getString(R.string.deleting_please_wait));
+ if (houseIdBean.getDebugType().equals(DebugType.NORMAL)) {
+ //銆愬父瑙勬柟寮忋�戝彂璧峰垹闄ょ數绔欐寚浠�
+ 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(position, houseIdBean, null);
+ }
+ });
+ } else {
+ //銆愮畝鏄撴柟寮忋�戝彂璧峰垹闄ょ數绔欐寚浠�
+ deleteResidence(position, houseIdBean, null);
}
-
- @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);
-// }
-// });
+ }
}
});
delayedConfirmationCancelDialog.setNoOnclickListener(new DelayedConfirmationCancelDialog.onNoOnclickListener() {
@@ -338,33 +393,40 @@
}
});
- //鐢电珯缂栬緫鎸夐挳
- viewBinding.editIv.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- startActivity(HouseListEditActivity.class);
- }
- });
- //鐢电珯鍚嶇О绛涢��
+ //PV绛涢��
viewBinding.stationNameRl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isSelected = !v.isSelected();
- viewBinding.stationNameRl.setSelected(isSelected);
- viewBinding.stationNameIv.setSelected(isSelected);
- key = SortType.homeNameSort;
+ screeningConditionStyle(viewBinding.stationNameRl, viewBinding.stationNameIv, isSelected);
+ key = SortType.installedCapacitySort;
value = isSelected ? SortValue.ascending : SortValue.descending;
+ getStatusOverview();
+ loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
}
});
- //鐢电珯鍙戠數鍔熺巼绛涢��
+ //棰濆畾鍔熺巼绛涢��
viewBinding.stationPowerRl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isSelected = !v.isSelected();
- viewBinding.stationPowerRl.setSelected(isSelected);
- viewBinding.stationPowerIv.setSelected(isSelected);
- key = SortType.powerSort;
+ screeningConditionStyle(viewBinding.stationPowerRl, viewBinding.stationPowerIv, isSelected);
+ key = SortType.invPowerSort;
value = isSelected ? SortValue.ascending : SortValue.descending;
+ getStatusOverview();
+ loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
+ }
+ });
+ //鐢电珯鐢垫睜瀹归噺绛涢��
+ viewBinding.stationMonthRl.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ boolean isSelected = !v.isSelected();
+ screeningConditionStyle(viewBinding.stationMonthRl, viewBinding.stationMonthIv, isSelected);
+ key = SortType.batteryCapacitySort;
+ value = isSelected ? SortValue.ascending : SortValue.descending;
+ getStatusOverview();
+ loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
}
});
//鐢电珯褰撴棩鍙戠數閲忕瓫閫�
@@ -372,63 +434,74 @@
@Override
public void onClick(View v) {
boolean isSelected = !v.isSelected();
- viewBinding.stationDayRl.setSelected(isSelected);
- viewBinding.stationDayIv.setSelected(isSelected);
+ screeningConditionStyle(viewBinding.stationDayRl, viewBinding.stationDayIv, isSelected);
key = SortType.todayElectricitySort;
value = isSelected ? SortValue.ascending : SortValue.descending;
- }
- });
- //鐢电珯褰撴湀鍙戠數閲忕瓫閫�
- viewBinding.stationMonthRl.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- boolean isSelected = !v.isSelected();
- viewBinding.stationMonthRl.setSelected(isSelected);
- viewBinding.stationMonthIv.setSelected(isSelected);
- key = SortType.monthElectricitySort;
- value = isSelected ? SortValue.ascending : SortValue.descending;
+ getStatusOverview();
+ loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
}
});
//璁惧鐐瑰嚮
deviceInfoAdapter.setOnclickListener(new DeviceInfoAdapter.OnClickListener() {
@Override
- public void onClick(int position, DeviceBean deviceBean) {
-
- }
- });
- //璁惧璁剧疆涓嬫媺绠ご棰滆壊
- viewBinding.fragmentDeviceSrl.setColorSchemeResources(R.color.text_FF245EC3);
- //璁惧涓嬫媺璇诲彇
- viewBinding.fragmentDeviceSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
- @Override
- public void onRefresh() {
- viewBinding.fragmentDeviceSrl.setRefreshing(false);
- loadNextPageDeviceList(false, 1, true);
- }
- });
- //璁惧涓婃媺璇诲彇
- viewBinding.fragmentDeviceSrlListRc.addOnScrollListener(new RecyclerView.OnScrollListener() {
- @Override
- public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
-// super.onScrolled(recyclerView, dx, dy);
-
- LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
- if (layoutManager == null) {
+ public void onClick(int position, CloudInverterDeviceBean deviceBean) {
+ deviceBean.setActivate(true);//榛樿婵�娲�
+// //鏉ㄦ稕璇磋繖涓垪琛ㄤ笉杩斿洖鏈縺娲荤殑璁惧锛屾墍浠ュ幓鎺夊垽鏂�
+// 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());
+// gatewayBean.setDevice_model(deviceBean.getOmodel());
+// gatewayBean.setOid(deviceBean.getOid());
+// gatewayBean.setGatewayId(deviceBean.getGatewayId());
+// gatewayBean.setAddresses(deviceBean.getAddresses());
+// gatewayBean.setSid(deviceBean.getSid());
+// gatewayBean.setDeviceId(deviceBean.getDeviceId());
+// gatewayBean.setDevice_name(deviceBean.getName());
+// gatewayBean.setDeviceStatus(deviceBean.getDeviceStatus());
+// gatewayBean.setHomeId(deviceBean.getHomeId());
+// gatewayBean.setSpk(deviceBean.getSpk());
+// gatewayBean.setDeviceType(deviceBean.getDeviceType());
+ if (deviceBean.getDeviceStatus() == 4) {
+ HdlThreadLogic.toast(_mActivity, R.string.device_off);
return;
}
- int visibleItemCount = layoutManager.getChildCount();
- int totalItemCount = layoutManager.getItemCount();
- int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
- if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) {
- if (!isDeviceLoadingMore) {
- // 婊戝姩鍒颁簡搴曢儴锛屾墽琛岀浉搴旂殑鎿嶄綔
- HdlLogLogic.print("---婊戝姩鍒颁簡搴曢儴");
- loadNextPageDeviceList(false, ++currentDeviceListPage, false);
+ //閰嶇疆鏈湴閫氫俊鐨勪俊鎭�
+ HDLLinkConfig.getInstance().setHomeId(deviceBean.getHomeId());
+ HDLLinkConfig.getInstance().setLocalSecret(deviceBean.getLocalSecret());
+ List<CloudInverterDeviceBean> newList = new ArrayList<>();
+ newList.add(deviceBean);
+ //鐩殑鏄负浜嗚幏鍙栨嬁鍒扮綉鍏矷D锛宮qtt閫氳绉橀挜绛変俊鎭紝鎷垮埌鍚庣紦瀛樺埌鏈湴閫嗗彉鍣ㄥ垪琛ㄩ噷闈紝鍙戦�佹暟鎹暟鎹椂鑷姩鍘荤紦瀛樺垪琛ㄩ噷闈㈠幓鏌ユ壘锛�
+ HdlDeviceLogic.getInstance().setDeviceRemoteInfo(newList, deviceBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() {
+ @Override
+ public void onSuccess(List<GatewayBean> obj) {
+
+ GatewayBean newGatewayBean = HDLLinkLocalGateway.getInstance().getLocalGateway(deviceBean.getOsn());
+ if (newGatewayBean == null) {
+ HdlThreadLogic.toast(_mActivity, getString(R.string.device_off));
+ return;
+ }
+ if (TextUtils.isEmpty(newGatewayBean.getGatewayId()) || TextUtils.isEmpty(newGatewayBean.getAesKey())) {
+ //杩欓噷鍙敮鎸佽繙绋嬭皟璇曪紝杩滅▼鎷夸笉鍒癿qtt閫氳绉橀挜浠ュ強gatewayId锛�
+ HdlThreadLogic.toast(_mActivity, getString(R.string.device_failed_to_certificate) + "(124004)");
+ return;
+ }
+ String jsonEncryption = URLEncodingUtils.encodeURIComponent(new Gson().toJson(newGatewayBean));
+ String path = HDLUniMP.UNI_EVENT_OPEN_DEVICE_DETAILS + "?inverterInfo=" + jsonEncryption;
+ HdlUniLogic.getInstance().openUniMP(path, null);
}
- }
+
+ @Override
+ public void onFailure(HDLException e) {
+
+ }
+ });
}
});
- //璁惧娣绘悳绱�
+ //璁惧鎼滅储
viewBinding.deviceSearchCl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -440,65 +513,100 @@
}
- private void initView() {
- viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);
- viewBinding.deviceLabelParent.setVisibility(View.GONE);
- viewBinding.powerStationAllIl.stationTitleTv.setText(getString(R.string.message_all));
- viewBinding.powerStationFaultsIl.stationTitleTv.setText(getString(R.string.my_power_station_malfunction));
- viewBinding.hpowerStationOfflineIl.stationTitleTv.setText(getString(R.string.my_power_station_off_line));
- viewBinding.powerStationConnectedIl.stationTitleTv.setText(getString(R.string.to_be_added));
+ /**
+ * 鏇存柊绛涢�夌數绔欑姸鎬佹牱寮�
+ *
+ * @param ll 缁勪欢鍚嶇О
+ * @param tv 缁勪欢鍚嶇О
+ */
+ private void stationStatusStyle(LinearLayout ll, TextView tv) {
+ viewBinding.allLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
+ viewBinding.faultsLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
+ viewBinding.offlineLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
+ viewBinding.connectedLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
+ viewBinding.allDesTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B));
+ viewBinding.faultsDesTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B));
+ viewBinding.offlineDesTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B));
+ viewBinding.connectedDesTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B));
- selectedStationStyle(viewBinding.powerStationAllIl.parentLl, viewBinding.powerStationAllIl.stationTotalTv, viewBinding.powerStationAllIl.stationTitleTv, true);
- //鐢电珯鏍囩
- houseInfoAdapter = new HouseInfoAdapter(_mActivity);
- viewBinding.fragmentHouseSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
- viewBinding.fragmentHouseSrlListRc.setAdapter(houseInfoAdapter);
- houseInfoAdapter.setList(this.houseListBeanIDList);
-
- //璁惧鏍囩
- deviceInfoAdapter = new DeviceInfoAdapter(_mActivity);
- viewBinding.fragmentDeviceSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
- viewBinding.fragmentDeviceSrlListRc.setAdapter(deviceInfoAdapter);
- this.nullDataUpdateUi();
-
+ ll.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_yes_ffffff));
+ tv.setTextColor(getResources().getColor(R.color.text_FFACACAC));
}
/**
- * 鏄剧ず閫変腑鐘舵�佹牱寮�
+ * 鏇存柊绛涢�夋潯浠剁姸鎬佹牱寮�
*
- * @param linearLayout 缁勪欢
- * @param numberTv 缁勪欢
- * @param titleTv 缁勪欢
- * @param isShowSelectedStatus 鏄惁鏄剧ず鐘舵�佹牱寮�
+ * @param relativeLayout 缁勪欢鍚嶇О
+ * @param imageView 缁勪欢鍚嶇О
+ * @param isSelected 鐘舵��
*/
- private void selectedStationStyle(LinearLayout linearLayout, TextView numberTv, TextView titleTv, boolean isShowSelectedStatus) {
- viewBinding.powerStationAllIl.parentLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
- viewBinding.powerStationFaultsIl.parentLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
- viewBinding.hpowerStationOfflineIl.parentLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
- viewBinding.powerStationConnectedIl.parentLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff));
-
- viewBinding.powerStationAllIl.stationTotalTv.setTextColor(getResources().getColor(R.color.text_E6000000, null));
- viewBinding.powerStationAllIl.stationTitleTv.setTextColor(getResources().getColor(R.color.text_66000000, null));
-
- viewBinding.powerStationFaultsIl.stationTotalTv.setTextColor(getResources().getColor(R.color.text_E6000000, null));
- viewBinding.powerStationFaultsIl.stationTitleTv.setTextColor(getResources().getColor(R.color.text_66000000, null));
-
- viewBinding.hpowerStationOfflineIl.stationTotalTv.setTextColor(getResources().getColor(R.color.text_E6000000, null));
- viewBinding.hpowerStationOfflineIl.stationTitleTv.setTextColor(getResources().getColor(R.color.text_66000000, null));
-
- viewBinding.powerStationConnectedIl.stationTotalTv.setTextColor(getResources().getColor(R.color.text_E6000000, null));
- viewBinding.powerStationConnectedIl.stationTitleTv.setTextColor(getResources().getColor(R.color.text_66000000, null));
+ private void screeningConditionStyle(RelativeLayout relativeLayout, ImageView imageView, boolean isSelected) {
+ viewBinding.stationNameRl.setSelected(false);
+ viewBinding.stationNameIv.setSelected(false);
+ viewBinding.stationPowerRl.setSelected(false);
+ viewBinding.stationPowerIv.setSelected(false);
+ viewBinding.stationDayRl.setSelected(false);
+ viewBinding.stationDayIv.setSelected(false);
+ viewBinding.stationMonthRl.setSelected(false);
+ viewBinding.stationMonthIv.setSelected(false);
+ relativeLayout.setSelected(isSelected);
+ imageView.setSelected(isSelected);
+ }
- if (isShowSelectedStatus) {
- linearLayout.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.selected_8_38c494));
- numberTv.setTextColor(getResources().getColor(R.color.text_FFFFFFFF, null));
- titleTv.setTextColor(getResources().getColor(R.color.text_FFFFFFFF, null));
+ private void initView() {
+ viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);
+ viewBinding.deviceLabelParent.setVisibility(View.GONE);
+
+ stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv);
+ //鐢电珯鏍囩
+ houseInfoAdapter = new HouseInfoAdapter(_mActivity);
+ 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));
+ viewBinding.fragmentDeviceSrlListRc.setAdapter(deviceInfoAdapter);
+ //
+// this.nullDataUpdateUi();
+ //涓嬫媺鍒锋柊浣忓畢鐨勯�昏緫
+ pullToRefreshHome();
+ //涓嬫媺鍒锋柊璁惧鐨勯�昏緫
+ pullToRefreshDevice();
+
+ }
+
+ /**
+ * 鐢电珯鍜岃澶囨爣绛炬牱寮�
+ */
+ private void selectedTitleLabelStyle() {
+ if (isClickPowerStationLabel) {
+ viewBinding.powerStationLabel.setTextAppearance(R.style.Text18Style);
+ viewBinding.deviceLabel.setTextAppearance(R.style.Text14Style);
+// viewBinding.editIv.setVisibility(View.VISIBLE);//缂栬緫鍥炬爣闅愯棌
+ viewBinding.addIv.setVisibility(View.VISIBLE);//娣诲姞鍥炬爣闅愯棌
+ viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);//鐢电珯鏍囩銆愮埗瀹瑰櫒銆戞樉绀�
+ viewBinding.deviceLabelParent.setVisibility(View.GONE);//璁惧鏍囩銆愮埗瀹瑰櫒銆戦殣钘�
+ if (viewBinding.deviceNullDataIc.getRoot().getVisibility() == View.VISIBLE) {
+ viewBinding.deviceNullDataIc.getRoot().setVisibility(View.GONE);
+ }
+ } else {
+ viewBinding.deviceLabel.setTextAppearance(R.style.Text18Style);
+ viewBinding.powerStationLabel.setTextAppearance(R.style.Text14Style);
+// viewBinding.editIv.setVisibility(View.GONE);//缂栬緫鍥炬爣闅愯棌
+ viewBinding.addIv.setVisibility(View.GONE);//娣诲姞鍥炬爣闅愯棌
+ viewBinding.powerStationLabelParent.setVisibility(View.GONE);//鐢电珯鏍囩銆愮埗瀹瑰櫒銆戦殣钘�
+ viewBinding.deviceLabelParent.setVisibility(View.VISIBLE);//璁惧鏍囩銆愮埗瀹瑰櫒銆戞樉绀�
+ if (viewBinding.homeNullDataIc.getRoot().getVisibility() == View.VISIBLE) {
+ viewBinding.homeNullDataIc.getRoot().setVisibility(View.GONE);
+ }
}
}
+
private void initData() {
if (isClickPowerStationLabel) {
@@ -506,8 +614,7 @@
this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList());
} else {
this.deviceInfoList = new ArrayList<>();
- this.deviceInfoList.add(new DeviceBean());
-// this.deviceInfoList.addAll(HdlDeviceLogic.getInstance().getListDevice());
+ this.deviceInfoList.addAll(HdlDeviceLogic.getInstance().getDeviceList());
}
@@ -525,15 +632,18 @@
if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
// 鍙栨秷绮樻�т簨浠�
EventBus.getDefault().removeStickyEvent(eventBus);
- //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
- loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
- if (eventBus.getData() != null) {
- Gson gson = new Gson();
- String json = eventBus.getData().toString();
- HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class);
- HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
-
- }
+// HdlLogLogic.print("杩涙潵浜�---11111" + eventBus.getData().toString());
+// //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
+// loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
+// if (eventBus.getData() != null) {
+// HdlLogLogic.print("杩涙潵浜�---" + eventBus.getData().toString());
+// Gson gson = new Gson();
+// String json = eventBus.getData().toString();
+// HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class);
+// HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true);
+// HdlLogLogic.print("杩涙潵浜�---缁撴潫" + eventBus.getData().toString());
+//
+// }
} else if (HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT.equals(eventBus.getType())) {
// 鍙栨秷绮樻�т簨浠�
EventBus.getDefault().removeStickyEvent(eventBus);
@@ -560,42 +670,88 @@
// }
// }
-
}
- } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE.equals(eventBus.getType())) {
+ } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE.equals(eventBus.getTopic())) {
// 鍙栨秷绮樻�т簨浠�
EventBus.getDefault().removeStickyEvent(eventBus);
- //uin鍏抽棴浣忓畢璇︽儏鐣岄潰閫氱煡
- if (MqttRecvClient.getInstance() != null) {
- MqttRecvClient.getInstance().removeAllTopic();
- }
- loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+ //鏄湪锛堢數绔欙級妯″潡涓斿湪锛堢數绔欙級鏍囩椤垫墠杩涙潵杩欓噷
+ if (HdlCommonLogic.lowerTagType == LowerTagType.power_station && isClickPowerStationLabel) {
+// //uin鍏抽棴浣忓畢璇︽儏鐣岄潰閫氱煡
+// if (MqttRecvClient.getInstance() != null) {
+// MqttRecvClient.getInstance().removeAllTopic();
+// }
+ loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
+ }
} else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) {
// 鍙栨秷绮樻�т簨浠�
EventBus.getDefault().removeStickyEvent(eventBus);
+// if (!isClickPowerStationLabel) {
+// return;
+// }
+ //鍏堟竻绌鸿闃呬富棰�
+ if (MqttRecvClient.getInstance() != null) {
+ MqttRecvClient.getInstance().removeAllTopic();
+ }
+ String homeId = eventBus.getData().toString();
//杩涘幓浣忓畢璇︽儏uni璇诲彇閫嗗彉鍣ㄥ垪琛ㄦ垚鍔熷悗閫氱煡
- for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(UserConfigManage.getInstance().getHomeId()).size(); i++) {
- String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(UserConfigManage.getInstance().getHomeId()).get(i).getGatewayId();
+ for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).size(); i++) {
+ String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).get(i).getGatewayId();
//瀛楃涓叉槸鑷繁鎸夎鍒欐嫾鎺ョ殑,閲岄潰娉ㄥ唽涓婚鏃朵細瑙f瀽瀛楃涓�,鍙嬁getGatewayId()鍊�;
String topic = "/user/" + gatewayId + "/#";
//杩涘幓浣忓畢璇︽儏寮�濮嬭闃呬富棰�
- MqttRecvClient.getInstance().checkAndsubscribeAllTopics(topic);
+ MqttRecvClient.getInstance().checkAndsubscribeAllTopics(topic);//璁㈤槄銆愰�嗗彉鍣ㄣ�戞秷鎭�
}
+ String topicHome = "/user/" + homeId + "/#";
+ MqttRecvClient.getInstance().checkAndsubscribeAllTopics(topicHome);//璁㈤槄銆愮數绔欍�戞秷鎭�
+
+
} else if (eventBus.getTopic().equals(ConstantManage.homepage_title_tab_switch)) {
+ // 鍙栨秷绮樻�т簨浠�
+ EventBus.getDefault().removeStickyEvent(eventBus);
//鎺ユ敹澶栭儴鐐瑰嚮浜嬩欢
if (eventBus.getType().equals(HomepageTitleTabSwitch.powerstation.toString())) {
+ HdlLogLogic.print("姝e湪鐐瑰嚮銆愮數绔欍��");
+// if (!isReadData) {
+// //1锛屼粠棣栭〉-鏁呴殰-杩涙潵-鐢电珯锛堜笉璇诲彇锛�
+// //2锛屼粠鐢电珯-杩涙潵-鐢电珯锛堣鍙栦竴娆�,鍚庨潰杩涙潵涓嶅湪璇诲彇锛�
+// loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+// getStatusOverview();
+// }
+ //2024骞�06鏈�24鏃�14:34:01 浜у搧缁忕悊瑕佹眰杩涘幓鐢电珯鍒楄〃閮借璇诲彇 涓旈粯璁よ繘鍘婚兘鏄粯璁ょ數绔欐爣绛�
+ isClickPowerStationLabel = true;
+ selectedTitleLabelStyle();
+ initializationState();
+ stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv);
+ getStatusOverview();
+ loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
+ } else if (eventBus.getType().equals(ConstantManage.station_page)) {
// 鍙栨秷绮樻�т簨浠�
EventBus.getDefault().removeStickyEvent(eventBus);
- HdlLogLogic.print("姝e湪鐐瑰嚮銆愮數绔欍��");
-// HdlThreadLogic.runSubThread(new Runnable() {
-// @Override
-// public void run() {
- loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+ isClickPowerStationLabel = true;
+ selectedTitleLabelStyle();
+ powerStationStatusValue = eventBus.getData() == null ? "" : eventBus.getData().toString();
+ //閫氳繃棣栭〉鐢电珯杩涙潵鐨�
+ if (eventBus.getData().equals(PowerStationStatus.All)) {
+ stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv);
+ } else if (eventBus.getData().equals(PowerStationStatus.malfunction)) {
+ stationStatusStyle(viewBinding.faultsLl, viewBinding.faultsDesTv);
+ } else if (eventBus.getData().equals(PowerStationStatus.off)) {
+ stationStatusStyle(viewBinding.offlineLl, viewBinding.offlineDesTv);
+ } else if (eventBus.getData().equals(PowerStationStatus.connecting)) {
+ stationStatusStyle(viewBinding.connectedLl, viewBinding.connectedDesTv);
+ }
getStatusOverview();
-// }
-// });
-
+ loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
+ } else if (eventBus.getType().equals(ConstantManage.station_edit)) {
+ //缂栬緫鍚庢洿鏂颁竴涓嬩綇瀹呭垪琛�
+ //loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+// getStatusOverview();
+ if (houseInfoAdapter != null) {
+ initData();
+ //鏇存柊UI
+ houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);
+ }
}
}
}
@@ -605,16 +761,16 @@
* 鐢电珯鐘舵�佹瑙�
*/
private void getStatusOverview() {
- HdlResidenceLogic.getInstance().getStatusOverview(new CloudCallBeak<StatusOverviewBean>() {
+ HdlResidenceLogic.getInstance().getStatusOverview(screeningConditionStatus, installedCapacityMinValue, installedCapacityMaxValue, new CloudCallBeak<StatusOverviewBean>() {
@Override
public void onSuccess(StatusOverviewBean statusOverviewBean) {
if (statusOverviewBean == null) {
return;
}
- viewBinding.powerStationAllIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getTotal()));
- viewBinding.powerStationFaultsIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getFault()));
- viewBinding.hpowerStationOfflineIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getOffline()));
- viewBinding.powerStationConnectedIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getConnecting()));
+ viewBinding.allTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getTotal()));
+ viewBinding.faultsTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getFault()));
+ viewBinding.offlineTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getOffline()));
+ viewBinding.connectedTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getConnecting()));
}
@Override
@@ -628,20 +784,22 @@
/**
* 鍒锋柊UI锛堢數绔欙級
*
- * @param isRefreshing 琛ㄧず鏄笅鎷夊埛鏂扮殑
+ * @param isRefreshing 鏄惁鏄剧ず鍔犺浇妗嗭紙true鏄剧ず锛宖alse涓嶆樉绀猴級
* @param key 鍙戠數鍔熺巼鎺掑簭(powerSort);
* 浠婃棩鍙戠數閲忔帓搴�(todayElectricitySort);
* 鍒涘缓鏃堕棿鎺掑簭(createTimeSort);
+ * 鐢垫睜瀹归噺鎺掑簭(batteryCapacitySort);
* @param keyValue (descending:闄嶅簭
* ascending:鍗囧簭),
* @param installedCapacityMin 鏈�灏忕粍涓插閲�(瑁呮満瀹归噺)
* @param installedCapacityMax 鏈�澶х粍涓插閲�(瑁呮満瀹归噺)
- * @param gridType 骞剁綉鐘舵�� (鍏ㄩ儴 锛�"";FULL_GRID 锛� 骞剁綉;OFFLINE 锛氱缃�)
+ * @param gridType 璋冭瘯鐘舵��(鍏ㄩ儴;璋冭瘯涓�;璋冭瘯瀹屾垚;宸蹭氦浠�;鎺堟潈璋冭瘯)
* @param powerStationStatus 鐢电珯鐘舵�� (鍏ㄩ儴 锛�"";1 锛� 姝e父;2 锛� 绂荤嚎; 3 锛� 寰呮帴鍏�;4 锛� 鏁呴殰)
* @param pageNo 椤电爜
* @param isClear 鏄惁娓呴櫎鏁版嵁
*/
private void loadNextPageHouseList(boolean isRefreshing, String key, String keyValue, String installedCapacityMin, String installedCapacityMax, String gridType, String powerStationStatus, long pageNo, boolean isClear) {
+ isReadData = true;
if (isClear) {
clearData();
}
@@ -653,7 +811,7 @@
}
isHouseLoadingMore = true;//鏍囪璇诲彇鐘舵��
if (isRefreshing) {
- showLoading();
+ showLoading(getString(R.string.device_loading));
}
//鑾峰彇浣忓畢(鐢电珯)ID鍒楄〃
@@ -675,7 +833,7 @@
if (houseInfoAdapter != null) {
initData();
//鏇存柊UI
- houseInfoAdapter.setList(houseListBeanIDList);
+ houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);
}
}
nullDataUpdateUi();
@@ -696,7 +854,7 @@
if (isRefreshing) {
hideLoading();
}
-
+ HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")");
}
}, _mActivity, ShowErrorMode.YES);
}
@@ -706,7 +864,7 @@
/**
* 鍒锋柊UI锛堣澶囷級
*
- * @param isRefreshing 琛ㄧず鏄笅鎷夊埛鏂扮殑
+ * @param isRefreshing 鏄惁鏄剧ず鍔犺浇妗嗭紙true鏄剧ず锛宖alse涓嶆樉绀猴級
* @param pageNo 椤电爜
* @param isClear true琛ㄧず娓呯┖缂撳瓨
*/
@@ -722,12 +880,12 @@
}
isDeviceLoadingMore = true;//鏍囪璇诲彇鐘舵��
if (isRefreshing) {
- showLoading();
+ showLoading(getString(R.string.device_loading));
}
- //鑾峰彇浣忓畢(鐢电珯)ID鍒楄〃
- HdlDeviceLogic.getInstance().getPowerStationDeviceList("", pageNo, pageSize, new CloudCallBeak<PageNumberObject<DeviceBean>>() {
+ //鑾峰彇璁惧鍒楄〃
+ HdlDeviceLogic.getInstance().getPowerStationDeviceList("", pageNo, pageSize, new CloudCallBeak<PageNumberObject<CloudInverterDeviceBean>>() {
@Override
- public void onSuccess(PageNumberObject<DeviceBean> pageNumberObject) {
+ public void onSuccess(PageNumberObject<CloudInverterDeviceBean> pageNumberObject) {
HdlThreadLogic.runMainThread(new Runnable() {
@Override
public void run() {
@@ -765,6 +923,7 @@
if (isRefreshing) {
hideLoading();
}
+ HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")");
}
}, _mActivity, ShowErrorMode.YES);
}
@@ -801,13 +960,17 @@
boolean is_data;
String tipText = "";
if (isClickPowerStationLabel) {
- is_data = houseListBeanIDList != null && houseListBeanIDList.size() > 0;
+ is_data = houseListBeanIDList != null && !houseListBeanIDList.isEmpty();
tipText = getString(R.string.my_power_station_data_null);
+ HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.homeNullDataIc.getRoot(), viewBinding.homeNullDataIc.nullDataGifAnimationIv, viewBinding.homeNullDataIc.nullDataTv, tipText, is_data);
+
} else {
- is_data = deviceInfoList != null && deviceInfoList.size() > 0;
+ is_data = deviceInfoList != null && !deviceInfoList.isEmpty();
tipText = getString(R.string.no_equipment);
+
+ HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.deviceNullDataIc.getRoot(), viewBinding.deviceNullDataIc.nullDataGifAnimationIv, viewBinding.deviceNullDataIc.nullDataTv, tipText, is_data);
+
}
- HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.nullDataIc.getRoot(), viewBinding.nullDataIc.nullDataGifAnimationIv, viewBinding.nullDataIc.nullDataTv, tipText, is_data);
}
/**
@@ -839,20 +1002,27 @@
/**
* 鍒犻櫎鐢电珯
*
- * @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); //鍙戣捣鍒濆鍖栨寚浠ょ粰閫嗗彉鍣�;锛堟敞鎰�:鍙兘鏄湰鍦板彂閫佷簡(瑕佹悳绱㈠眬鍩熺綉閫嗗彉鍣ㄥ垪琛紝寤虹珛鏈湴閫氳閫氶亾),鍒犻櫎鐢电珯鎴愬姛鍚�,浜戠瑙g粦閫嗗彉鍣ㄧ殑鍏崇郴锛�
- HdlResidenceLogic.getInstance().delHouseId(homeId);//鍒犻櫎鐢电珯缂撳瓨
+ if (houseIdBean.getDebugType().equals(DebugType.NORMAL)) {
+ initializeInverter(list); //鍙戣捣鍒濆鍖栨寚浠ょ粰閫嗗彉鍣�;锛堟敞鎰�:鍓嶉潰宸插厛瑙g粦浜戠閫嗗彉鍣紝mqtt閫氶亾宸叉柇寮�锛屽垵濮嬪寲鍙兘鏄湰鍦板彂閫�(鍏堟悳绱㈠眬鍩熺綉閫嗗彉鍣ㄥ垪琛紝寤虹珛鏈湴閫氳閫氶亾)锛�
+ }
+ HdlResidenceLogic.getInstance().delHouseId(houseIdBean.getHomeId());//鍒犻櫎鐢电珯缂撳瓨
initData();//鍒濆鍖栫紦瀛樻暟鎹�
- houseInfoAdapter.setList(houseListBeanIDList);//閲嶆柊鍒锋柊鍒楄〃
+ if (houseInfoAdapter != null) {
+ houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//閲嶆柊鍒锋柊鍒楄〃
+// houseInfoAdapter.notifyItemRemoved(position);//鍙埛鏂板綋鍓嶇殑浣嶇疆
+ }
+ getStatusOverview();//鍒犻櫎鎴愬姛鍚庡埛鏂扮數绔欑姸鎬佹瑙�
nullDataUpdateUi();//妫�娴嬫暟鎹槸鍚︿负绌�
}
@@ -871,13 +1041,18 @@
if (requestCode == PermissionUtils.STATUS_SUCCESS) {
for (int i = 0; i < permissions.length; i++) {
if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
- if (mPermissionsResultCallback != null) {
- mPermissionsResultCallback.succeed();
+ switch (permissions[i]) {
+ case Manifest.permission.ACCESS_FINE_LOCATION: {
+ UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
+ HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+ locationUpdates();
+ }
+ break;
}
+
} else {
- if (mPermissionsResultCallback != null) {
- mPermissionsResultCallback.failing();
- }
+ HdlDialogLogic.getInstance().showSettingPermissionDialog(_mActivity, _mActivity.getString(R.string.set_location_permissions));
+ break;
}
}
@@ -885,15 +1060,196 @@
}
+ public void requestPermissions(OnCallBeak onCallBeak) {
- private PermissionsResultCallback mPermissionsResultCallback;
+ //ACCESS_FINE_LOCATION 鍏佽浣跨敤GPS瀹氫綅
+ //ACCESS_COARSE_LOCATION 鍏佽浣跨敤WIFI鐑偣鎴栧熀绔欐潵鑾峰彇绮楃暐鐨勫畾浣�
+ String[] ary = PermissionUtils.checkPermission(_mActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION});
+ if (ary.length > 0) {
+ this.requestPermissions(ary, PermissionUtils.STATUS_SUCCESS);
+ } else {
+ 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();
+ }
+ });
+ }
- public interface PermissionsResultCallback {
+ }
- void succeed();
+ /**
+ * 鍒濆鍖栥�愬紑鍚畾浣嶃�戝拰銆愪綅缃俊鎭�戞潈闄�
+ */
+ private void locationUpdates() {
+ // 鍒濆鍖朙ocationManager瀵硅薄
+ LocationManager locationManager = (LocationManager) _mActivity.getSystemService(Context.LOCATION_SERVICE);
+ GPSManagerUtils.getInstance().getLocation(_mActivity);
+ // 鍒ゆ柇璁惧鏄惁鏀寔瀹氫綅鍔熻兘
+ if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
+ // 鎻愮ず鐢ㄦ埛鎵撳紑瀹氫綅鍔熻兘鎴栬�呭紩瀵肩敤鎴峰幓绯荤粺璁剧疆椤甸潰鎵撳紑瀹氫綅鍔熻兘
+ ConfirmationCancelDialog confirmationCancelDialog = new ConfirmationCancelDialog(_mActivity);
+ confirmationCancelDialog.setContent(getString(R.string.system_positioning_switch));
+ confirmationCancelDialog.setConfirmation(getString(R.string.go_to_settings));
+ confirmationCancelDialog.show();
+ confirmationCancelDialog.isHideTitle(true);
+ confirmationCancelDialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() {
+ @Override
+ public void Confirm() {
+ confirmationCancelDialog.dismiss();
+ Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ HDLApp.getInstance().startActivity(intent);
- void failing();
+ }
+ });
+ confirmationCancelDialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() {
+ @Override
+ public void Cancel() {
+ confirmationCancelDialog.dismiss();
+ }
+ });
+ }
+
+ }
+
+
+ /**
+ * 涓嬫媺鍒锋柊銆愪綇瀹呫�戠殑閫昏緫
+ */
+ protected void pullToRefreshHome() {
+ viewBinding.fragmentHouseSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() {
+ @Override
+ public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) {
+ new AsyncTask<Void, Void, Void>() {
+
+ @Override
+ protected Void doInBackground(Void... params) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void aVoid) {
+ // 鎵ц浠诲姟锛堝鏇存柊UI銆佽烦杞瓑锛�
+ viewBinding.fragmentHouseSrl.endRefreshing();
+ //鍔犺浇鏈�鏂版暟鎹畬鎴�
+ loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
+ getStatusOverview();
+ }
+ }.execute();
+
+
+ }
+
+
+ @Override
+ public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) {
+ new AsyncTask<Void, Void, Void>() {
+ @Override
+ protected Void doInBackground(Void... params) {
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void aVoid) {
+ viewBinding.fragmentHouseSrl.endLoadingMore();
+ if (!isHouseLoadingMore) {
+ // 婊戝姩鍒颁簡搴曢儴锛屾墽琛岀浉搴旂殑鎿嶄綔
+ loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, ++currentHouseListPage, false);
+ }
+ }
+ }.execute();
+ return true;
+ }
+ });
+ HDLRefreshViewHolder hdlRefreshViewHolder = new HDLRefreshViewHolder(_mActivity, true);
+ hdlRefreshViewHolder.setPullDownImageResource(R.mipmap.loading_44);
+ hdlRefreshViewHolder.setChangeToReleaseRefreshAnimResId(R.drawable.loading_refresh);
+ hdlRefreshViewHolder.setRefreshingAnimResId(R.drawable.loading_refresh_end);
+ viewBinding.fragmentHouseSrl.setRefreshViewHolder(hdlRefreshViewHolder);
+ }
+
+ /**
+ * 涓嬫媺鍒锋柊銆愯澶囥�戠殑閫昏緫
+ */
+ protected void pullToRefreshDevice() {
+ viewBinding.fragmentDeviceSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() {
+ @Override
+ public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) {
+
+ new AsyncTask<Void, Void, Void>() {
+ @Override
+ protected Void doInBackground(Void... params) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void aVoid) {
+ viewBinding.fragmentDeviceSrl.endRefreshing();
+ loadNextPageDeviceList(false, 1, true);
+ }
+ }.execute();
+ }
+
+ @Override
+ public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) {
+ new AsyncTask<Void, Void, Void>() {
+ @Override
+ protected Void doInBackground(Void... params) {
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void aVoid) {
+ // 鎵ц浠诲姟锛堝鏇存柊UI銆佽烦杞瓑锛�
+ viewBinding.fragmentDeviceSrl.endLoadingMore();
+ if (!isDeviceLoadingMore) {
+ // 婊戝姩鍒颁簡搴曢儴锛屾墽琛岀浉搴旂殑鎿嶄綔
+ loadNextPageDeviceList(false, ++currentDeviceListPage, false);
+ }
+ }
+ }.execute();
+ return true;
+ }
+ });
+ HDLRefreshViewHolder hdlRefreshViewHolder = new HDLRefreshViewHolder(_mActivity, true);
+ hdlRefreshViewHolder.setPullDownImageResource(R.mipmap.loading_44);
+ hdlRefreshViewHolder.setChangeToReleaseRefreshAnimResId(R.drawable.loading_refresh);
+ hdlRefreshViewHolder.setRefreshingAnimResId(R.drawable.loading_refresh_end);
+ viewBinding.fragmentDeviceSrl.setRefreshViewHolder(hdlRefreshViewHolder);
}
--
Gitblit v1.8.0