From a4e8dee87338beef6f45f053d8fa9c36dc74ed09 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期一, 06 五月 2024 19:53:17 +0800
Subject: [PATCH] 2024年05月06日19:53:11
---
app/src/main/java/com/hdl/photovoltaic/ui/adapter/DeviceInfoAdapter.java | 112 +++++
app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java | 142 +++++-
app/src/main/res/layout/activity_my_power_station.xml | 1
app/src/main/res/layout/item_plant_details.xml | 16
app/src/main/java/com/hdl/photovoltaic/enums/PowerStationStatus.java | 10
app/src/main/java/com/hdl/photovoltaic/bean/PageNumberObject.java | 61 ++
app/src/main/java/com/hdl/photovoltaic/internet/api/HttpApi.java | 8
app/src/main/res/drawable/device_image.png | 0
app/src/main/java/com/hdl/photovoltaic/enums/SortType.java | 45 ++
app/src/main/java/com/hdl/photovoltaic/ui/bean/CloudInverterDeviceBean.java | 2
app/src/main/java/com/hdl/photovoltaic/enums/SortValue.java | 7
app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java | 7
app/src/main/java/com/hdl/photovoltaic/ui/bean/DeviceBean.java | 78 +++
app/src/main/java/com/hdl/photovoltaic/enums/GridType.java | 8
app/src/main/res/layout/item_device_details.xml | 210 +++++++++
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java | 444 +++++++++++++++-----
app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java | 112 +++++
17 files changed, 1,116 insertions(+), 147 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/bean/PageNumberObject.java b/app/src/main/java/com/hdl/photovoltaic/bean/PageNumberObject.java
new file mode 100644
index 0000000..f73b6c9
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/bean/PageNumberObject.java
@@ -0,0 +1,61 @@
+package com.hdl.photovoltaic.bean;
+
+import com.hdl.photovoltaic.ui.bean.MessageBean;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+public class PageNumberObject<T> implements Serializable {
+ //鎬绘潯鏁�
+ private long totalCount;
+ //鎬婚〉鏁�
+ private long totalPage;
+ //褰撳墠椤�
+ private long pageNo;
+ //椤垫暟
+ private long pageSize;
+ //娑堟伅鍒楄〃
+ private List<T> list;
+
+ public long getTotalCount() {
+ return totalCount;
+ }
+
+ public void setTotalCount(long totalCount) {
+ this.totalCount = totalCount;
+ }
+
+ public long getTotalPage() {
+ return totalPage;
+ }
+
+ public void setTotalPage(long totalPage) {
+ this.totalPage = totalPage;
+ }
+
+ public long getPageNo() {
+ return pageNo;
+ }
+
+ public void setPageNo(long pageNo) {
+ this.pageNo = pageNo;
+ }
+
+ public long getPageSize() {
+ return pageSize;
+ }
+
+ public void setPageSize(long pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ public List<T> getList() {
+ return list == null ? new ArrayList<>() : list;
+ }
+
+ public void setList(List<T> list) {
+ this.list = list;
+ }
+}
+
diff --git a/app/src/main/java/com/hdl/photovoltaic/enums/GridType.java b/app/src/main/java/com/hdl/photovoltaic/enums/GridType.java
new file mode 100644
index 0000000..27cc4b5
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/enums/GridType.java
@@ -0,0 +1,8 @@
+package com.hdl.photovoltaic.enums;
+
+public @interface GridType {
+ String All = "";//鍏ㄩ儴
+ String FULL_GRID = "FULL_GRID";//骞剁綉
+ String OFFLINE = "OFFLINE";//绂荤綉
+
+}
diff --git a/app/src/main/java/com/hdl/photovoltaic/enums/PowerStationStatus.java b/app/src/main/java/com/hdl/photovoltaic/enums/PowerStationStatus.java
new file mode 100644
index 0000000..9ede726
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/enums/PowerStationStatus.java
@@ -0,0 +1,10 @@
+package com.hdl.photovoltaic.enums;
+
+public @interface PowerStationStatus {
+ String All = "";//鍏ㄩ儴
+ String normal = "1";//姝e父(杩愯)
+ String off = "2";//绂荤嚎
+ String connecting = "3";//杩炴帴涓�(寰呮帴鍏�)
+ String malfunction = "4";//鏁呴殰
+ String off_malfunction = "4";//绂荤嚎鏈夋晠闅�
+}
diff --git a/app/src/main/java/com/hdl/photovoltaic/enums/SortType.java b/app/src/main/java/com/hdl/photovoltaic/enums/SortType.java
new file mode 100644
index 0000000..c8dfdce
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/enums/SortType.java
@@ -0,0 +1,45 @@
+package com.hdl.photovoltaic.enums;
+
+/**
+ * 鎺掑簭绫诲瀷
+ */
+public @interface SortType {
+
+ String homeName = "homeName";//
+ /**
+ * 鐢电珯鍚嶇О鎺掑簭
+ */
+ String homeNameSort = "homeNameSort";//鐢电珯鍚嶇О鎺掑簭
+ /**
+ * 鍙戠數鍔熺巼鎺掑簭
+ */
+ String powerSort = "powerSort";//鍙戠數鍔熺巼鎺掑簭
+ /**
+ * 浠婃棩鍙戠數閲忔帓搴�
+ */
+ String todayElectricitySort = "todayElectricitySort";//浠婃棩鍙戠數閲忔帓搴�
+ /**
+ * 褰撴湀鍙戠數閲�
+ */
+ String monthElectricitySort = "monthElectricitySort";//褰撴湀鍙戠數閲�
+ /**
+ * 鍒涘缓鏃堕棿鎺掑簭
+ */
+ String createTimeSort = "createTimeSort";//鍒涘缓鏃堕棿鎺掑簭
+ /**
+ * installedCapacityMin 鏈�灏忕粍涓插閲�(瑁呮満瀹归噺)
+ */
+ String installedCapacityMin = "installedCapacityMin";//installedCapacityMin 鏈�灏忕粍涓插閲�(瑁呮満瀹归噺)
+ /**
+ * 澶х粍涓插閲�(瑁呮満瀹归噺)
+ */
+ String installedCapacityMax = "installedCapacityMax";//澶х粍涓插閲�(瑁呮満瀹归噺)
+ /**
+ * 骞剁綉鐘舵��
+ */
+ String gridType = "gridType";//骞剁綉鐘舵��
+ /**
+ * 鐢电珯鐘舵��
+ */
+ String powerStationStatus = "powerStationStatus";//鐢电珯鐘舵��
+}
diff --git a/app/src/main/java/com/hdl/photovoltaic/enums/SortValue.java b/app/src/main/java/com/hdl/photovoltaic/enums/SortValue.java
new file mode 100644
index 0000000..0788e39
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/enums/SortValue.java
@@ -0,0 +1,7 @@
+package com.hdl.photovoltaic.enums;
+
+public @interface SortValue {
+ String all = "";//鍏ㄩ儴
+ String descending = "descending";//闄嶅簭
+ String ascending = "ascending";//鍗囧簭
+}
diff --git a/app/src/main/java/com/hdl/photovoltaic/internet/api/HttpApi.java b/app/src/main/java/com/hdl/photovoltaic/internet/api/HttpApi.java
index 46a7c56..8d79a86 100644
--- a/app/src/main/java/com/hdl/photovoltaic/internet/api/HttpApi.java
+++ b/app/src/main/java/com/hdl/photovoltaic/internet/api/HttpApi.java
@@ -121,9 +121,17 @@
public static final String B_POST_GET_USERINFO = "/basis-footstone/mgmt/user/oauth/getUserInfo";
+
+
//閫�鍑虹櫥褰�
public static final String POST_GET_IMAGE_LOGOUT = "/basis-footstone/mgmt/user/oauth/logout";
//endregion
+ //鑾峰彇璁惧鍒楄〃(瀹夎鍟�)
+ public static final String POST_deviceList = "/home-wisdom/app/powerStation/deviceList";
+ //鐢电珯鐘舵�佹瑙�(瀹夎鍟�)
+ public static final String POST_statusOverview = "/home-wisdom/app/powerStation/statusOverview";
+
+
//endregion
diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
index efd2bd2..363da34 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -9,6 +9,7 @@
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.hdl.linkpm.sdk.core.exception.HDLException;
+import com.hdl.photovoltaic.bean.PageNumberObject;
import com.hdl.photovoltaic.config.AppConfigManage;
import com.hdl.photovoltaic.config.UserConfigManage;
import com.hdl.photovoltaic.internet.HttpClient;
@@ -19,8 +20,11 @@
import com.hdl.photovoltaic.listener.LinkCallBack;
import com.hdl.photovoltaic.ui.bean.CloudInverterChildDeviceBean;
import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean;
+import com.hdl.photovoltaic.ui.bean.DeviceBean;
import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo;
import com.hdl.photovoltaic.ui.bean.DeviceTimeBean;
+import com.hdl.photovoltaic.ui.bean.HouseInfoBean;
+import com.hdl.photovoltaic.ui.bean.MessageBean;
import com.hdl.photovoltaic.ui.bean.OidBean;
import com.hdl.sdk.link.HDLLinkLocalSdk;
import com.hdl.sdk.link.common.config.TopicConstant;
@@ -71,7 +75,23 @@
public static final String kWh = "kW.h";
public static final String kW = "kW";
+ private List<DeviceBean> mListDevice = new ArrayList<>();
+ public void clearDeviceList() {
+ if (mListDevice == null) {
+ return;
+ }
+ if (mListDevice.size() > 0) {
+ mListDevice.clear();
+ }
+ }
+
+ public List<DeviceBean> getDeviceList() {
+ if (mListDevice == null) {
+ return new ArrayList<>();
+ }
+ return mListDevice;
+ }
/**
* 鑾峰彇褰撳墠浣忓畢鐨勯�嗗彉鍣ㄥ垪琛�(鍖呮嫭浠庣殑閫嗗彉鍣�)
@@ -150,6 +170,98 @@
}
}
+ /**
+ * 鑾峰彇璁惧鍒楄〃(瀹夎鍟�)
+ *
+ * @param searchTxt 鎼滅储鍐呭
+ * @param pageNo 椤电爜
+ * @param pageSize 椤垫暟
+ */
+ public void getPowerStationDeviceList(String searchTxt, long pageNo, long pageSize, CloudCallBeak<PageNumberObject<DeviceBean>> cloudCallBeak) {
+ String requestUrl = HttpApi.POST_deviceList;
+ JsonObject json = new JsonObject();
+ if (!TextUtils.isEmpty(searchTxt)) {
+ json.addProperty("searchTxt", searchTxt);
+ }
+ json.addProperty("pageNo", pageNo);//椤电爜
+ json.addProperty("pageSize", pageSize);//椤垫暟
+// json.addProperty("zoneType", zoneType);//鍖哄煙
+ HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
+ @Override
+ public void onSuccess(String jsonStr) {
+ if (TextUtils.isEmpty(jsonStr)) {
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(new PageNumberObject<>());
+ }
+ }
+ Gson gson = new Gson();
+ Type type = new TypeToken<PageNumberObject<DeviceBean>>() {
+ }.getType();
+ PageNumberObject<DeviceBean> pageNumberObject = gson.fromJson(jsonStr, type);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(pageNumberObject);
+ }
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onFailure(e);
+ }
+ }
+ });
+ }
+
+ /**
+ * 娣诲姞銆愯澶囧垪琛ㄣ�戝埌鏈湴缂撳瓨
+ *
+ * @param list -璁惧鍒楄〃
+ */
+ public void setListDevice(List<DeviceBean> list) {
+ try {
+ if (list == null || list.size() == 0) {
+ return;
+ }
+ if (this.mListDevice.size() == 0) {
+ this.mListDevice.addAll(list);
+ return;
+ }
+ for (int i = 0; i < list.size(); i++) {
+ this.setSingleDevice(list.get(i));
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ /**
+ * 娣诲姞璁惧鍒板垪琛ㄩ噷闈�
+ *
+ * @param deviceBean -璁惧瀵硅薄
+ */
+ public void setSingleDevice(DeviceBean deviceBean) {
+ try {
+ if (deviceBean == null) {
+ return;
+ }
+ boolean if_boolean = false;
+ for (int i = 0; i < mListDevice.size(); i++) {
+ if (mListDevice.get(i).getOsn().equals(deviceBean.getOsn())) {
+ //瀛樺湪鏇挎崲
+ mListDevice.remove(i);
+ mListDevice.add(i, deviceBean);
+ if_boolean = true;
+ break;
+ }
+ }
+ if (!if_boolean) {
+ //娌℃湁娣诲姞
+ this.mListDevice.add(deviceBean);
+ }
+ } catch (Exception e) {
+ String mes = e.getMessage();
+ HdlLogLogic.print("--->" + mes);
+ }
+ }
/**
* 閫嗗彉鍣ㄤ笂浼犳暟鎹埌浜戠(鍖呮嫭:sid锛宱id)
diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
index a21d962..a7b54f7 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
@@ -16,6 +16,7 @@
import com.hdl.photovoltaic.listener.BaseSuccessFailureCallBeak;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean;
+import com.hdl.photovoltaic.ui.bean.DeviceBean;
import com.hdl.photovoltaic.ui.bean.HouseInfoBean;
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
import com.hdl.photovoltaic.ui.bean.MessageBean;
@@ -74,21 +75,68 @@
this.houseInfoList = houseInfoList;
}
+ public void clearHouseList() {
+ if (houseInfoList == null) {
+ return;
+ }
+ if (houseInfoList.size() > 0) {
+ houseInfoList.clear();
+ }
+ }
+
+
/**
* 鑾峰彇缂撳瓨浣忓畢ID鍒楄〃
*
* @return 浣忓畢ID鍒楄〃
*/
public List<HouseIdBean> getHouseIdList() {
- return houseIdList;
+ return mHouseIdList;
}
- public void setHouseIdList(List<HouseIdBean> houseIdList) {
- if (houseIdList == null) {
- houseIdList = new ArrayList<>();
+ public void setHouseIdList(List<HouseIdBean> list) {
+ if (list == null || list.size() == 0) {
+ return;
}
- this.houseIdList = houseIdList;
+ if (this.mHouseIdList.size() == 0) {
+ this.mHouseIdList.addAll(list);
+ return;
+ }
+ for (int i = 0; i < list.size(); i++) {
+ this.setSingleHouseId(list.get(i));
+ }
}
+
+ /**
+ * 娣诲姞鐢电珯Id鍒板垪琛ㄩ噷闈�
+ *
+ * @param houseIdBean -鐢电珯Id瀵硅薄
+ */
+ public void setSingleHouseId(HouseIdBean houseIdBean) {
+ try {
+ if (houseIdBean == null) {
+ return;
+ }
+ boolean if_boolean = false;
+ for (int i = 0; i < mHouseIdList.size(); i++) {
+ if (mHouseIdList.get(i).getHomeId().equals(houseIdBean.getHomeId())) {
+ //瀛樺湪鏇挎崲
+ mHouseIdList.remove(i);
+ mHouseIdList.add(i, houseIdBean);
+ if_boolean = true;
+ break;
+ }
+ }
+ if (!if_boolean) {
+ //娌℃湁娣诲姞
+ this.mHouseIdList.add(houseIdBean);
+ }
+ } catch (Exception e) {
+ String mes = e.getMessage();
+ HdlLogLogic.print("--->" + mes);
+ }
+ }
+
/**
* 鍒犻櫎鐢电珯
@@ -99,9 +147,9 @@
if (TextUtils.isEmpty(houseId)) {
return;
}
- for (int i = 0; i < houseIdList.size(); i++) {
- if (houseIdList.get(i).getHomeId().equals(houseId)) {
- houseIdList.remove(i);
+ for (int i = 0; i < mHouseIdList.size(); i++) {
+ if (mHouseIdList.get(i).getHomeId().equals(houseId)) {
+ mHouseIdList.remove(i);
break;
}
}
@@ -117,8 +165,8 @@
return;
}
int index = -1;
- for (int i = 0; i < houseIdList.size(); i++) {
- if (houseIdList.get(i).getHomeId().equals(houseId)) {
+ for (int i = 0; i < mHouseIdList.size(); i++) {
+ if (mHouseIdList.get(i).getHomeId().equals(houseId)) {
index = i;
break;
}
@@ -128,12 +176,12 @@
}
//index==0琛ㄧず鍙湁涓�涓厓绱犳垨鑰呭湪棣栦綅,涓嶉渶瑕佺Щ鍔ㄤ綅缃�
if (index > 0) {
- Collections.swap(houseIdList, index - 1, index);
+ Collections.swap(mHouseIdList, index - 1, index);
}
}
//浣忓畢ID鍒楄〃
- private List<HouseIdBean> houseIdList = new ArrayList<>();
+ private List<HouseIdBean> mHouseIdList = new ArrayList<>();
//浣忓畢璇︽儏鍒楄〃
private List<HouseInfoBean> houseInfoList = new ArrayList<>();
@@ -149,12 +197,12 @@
@Override
public void onSuccess(List<HouseIdBean> houseListBeanIDList) {
if (houseListBeanIDList != null && houseListBeanIDList.size() > 0) {
- houseIdList.clear();
- houseIdList.addAll(houseListBeanIDList);
+ mHouseIdList.clear();
+ mHouseIdList.addAll(houseListBeanIDList);
//璁板綍璇锋眰鏉℃暟
AtomicInteger atomicInteger = new AtomicInteger(0);
- for (int i = 0; i < houseIdList.size(); i++) {
- HouseIdBean houseIdBean = houseIdList.get(i);
+ for (int i = 0; i < mHouseIdList.size(); i++) {
+ HouseIdBean houseIdBean = mHouseIdList.get(i);
//鑾峰彇浣忓畢璇︽儏鍒楄〃
getResidenceInfo(houseIdBean.getHomeId(), new CloudCallBeak<HouseInfoBean>() {
@Override
@@ -169,7 +217,7 @@
//娣诲姞鍒版湰鍦扮紦瀛�
addHouseToLocalMemory(houseInfoBean);
}
- if (atomicInteger.get() == houseIdList.size()) {
+ if (atomicInteger.get() == mHouseIdList.size()) {
//鏈�鍚庝竴鏉¢��鍑�
if (cloudCallBeak != null) {
cloudCallBeak.onSuccess(true);
@@ -181,7 +229,7 @@
@Override
public void onFailure(HDLException e) {
atomicInteger.set(atomicInteger.get() + 1);
- if (atomicInteger.get() == houseIdList.size()) {
+ if (atomicInteger.get() == mHouseIdList.size()) {
//鏈�鍚庝竴鏉¢��鍑�
if (cloudCallBeak != null) {
cloudCallBeak.onFailure(e);
@@ -279,6 +327,56 @@
}
});
}
+
+ }
+
+ @Override
+ public void onFailure(HDLException exception) {
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onFailure(exception);
+ }
+ }
+ });
+
+
+ }
+
+ /**
+ * 鑾峰彇浣忓畢(鐢电珯)ID鍒楄〃
+ *
+ * @param key 鍙戠數鍔熺巼鎺掑簭(powerSort);
+ * 浠婃棩鍙戠數閲忔帓搴�(todayElectricitySort);
+ * 鍒涘缓鏃堕棿鎺掑簭(createTimeSort);
+ * @param keyValue (descending:闄嶅簭
+ * ascending:鍗囧簭),
+ * @param pageNo 椤电爜
+ * @param pageSize 椤垫暟锛堜竴椤靛灏戞暟鎹級
+ */
+ public void getResidenceIdList(String key, String keyValue, long pageNo, long pageSize, CloudCallBeak<HouseBeanClass> cloudCallBeak) {
+
+ String requestUrl = HttpApi.POST_PowerStation_List;
+ JsonObject json = new JsonObject();
+ if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(keyValue)) {
+ json.addProperty(key, keyValue);//鍙戠數鍔熺巼鎺掑簭(descending:闄嶅簭ascending:鍗囧簭)
+ }
+// json.addProperty("zoneType", "password");//鍖哄煙
+ json.addProperty("pageNo", pageNo);//椤电爜
+ json.addProperty("pageSize", pageSize);//椤垫暟
+ HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
+ @Override
+ public void onSuccess(String jsonStr) {
+ if (TextUtils.isEmpty(jsonStr)) {
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(new HouseBeanClass());
+ }
+ return;
+ }
+ Gson gson = new Gson();
+ HouseBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseBeanClass.class);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(houseInfoBeanClass);
+ }
+
}
@@ -655,9 +753,9 @@
* @return 鍒楄〃绱㈠紩
*/
public HouseIdBean getHouseId(String homeId) {
- for (int i = 0; i < houseIdList.size(); i++) {
- if (houseIdList.get(i).getHomeId().equals(homeId)) {
- return houseIdList.get(i);
+ for (int i = 0; i < mHouseIdList.size(); i++) {
+ if (mHouseIdList.get(i).getHomeId().equals(homeId)) {
+ return mHouseIdList.get(i);
}
}
return null;
@@ -760,7 +858,7 @@
}
- static class HouseBeanClass {
+ public static class HouseBeanClass {
//鎬绘潯鏁�
private long totalCount;
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/adapter/DeviceInfoAdapter.java b/app/src/main/java/com/hdl/photovoltaic/ui/adapter/DeviceInfoAdapter.java
new file mode 100644
index 0000000..8a1bb87
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/adapter/DeviceInfoAdapter.java
@@ -0,0 +1,112 @@
+package com.hdl.photovoltaic.ui.adapter;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.hdl.photovoltaic.R;
+import com.hdl.photovoltaic.ui.bean.DeviceBean;
+import com.hdl.photovoltaic.widget.SwipeLayout;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DeviceInfoAdapter extends RecyclerView.Adapter<DeviceInfoAdapter.MyViewHolder> {
+
+ List<DeviceBean> mList;
+
+ Context mContext;
+
+ OnClickListener mOnclickListener;
+
+ public DeviceInfoAdapter(Context context) {
+
+ this.mContext = context;
+ }
+
+ @NonNull
+ @Override
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ View contentItem = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_device_details, parent, false);
+ return new MyViewHolder(contentItem);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
+ DeviceBean deviceBean = this.mList.get(position);
+ holder.itemView.setTag(position);
+ holder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ try {
+ if (mOnclickListener != null) {
+ mOnclickListener.onClick((int) holder.item_parent_rl.getTag(), deviceBean);
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ });
+
+ }
+
+ @Override
+ public int getItemCount() {
+ return this.mList == null ? 0 : this.mList.size();
+ }
+
+ public void setOnclickListener(OnClickListener onClickListener) {
+ this.mOnclickListener = onClickListener;
+ }
+
+ public void setList(List<DeviceBean> newData) {
+ if (this.mList == null) {
+ this.mList = new ArrayList<>();
+ } else {
+ this.mList.clear();
+ }
+
+ this.mList.addAll(newData);
+ notifyDataSetChanged();
+ }
+
+ /**
+ * 涓�琛屽竷灞�瀹瑰櫒
+ */
+ static class MyViewHolder extends RecyclerView.ViewHolder {
+
+ public ImageView homeIconIv;//浣忓畢鍥剧墖
+ public TextView homeNameTv;//浣忓畢鍚嶇О
+ public TextView capacityTv;//瑁呮満瀹归噺
+ public TextView powerTv;//鍙戠數鍔熺巼
+ public TextView stateTv;//鐢电珯鐘舵��(杩炴帴涓�,杩愯,绂荤嚎,鏁呴殰);
+ public RelativeLayout item_parent_rl;//鏉$洰鐖跺鍣�
+ public ImageView move_home_iv;//绉诲姩鐢电珯浣嶇疆
+ public ImageView del_home_iv;//鍒犻櫎鐢电珯
+ public SwipeLayout item_parent_swipeLayout;//鐖跺鍣�
+
+ public MyViewHolder(@NonNull View itemView) {
+ super(itemView);
+ homeIconIv = itemView.findViewById(R.id.device_details_image_iv);
+ homeNameTv = itemView.findViewById(R.id.device_details_name_tv);
+ capacityTv = itemView.findViewById(R.id.device_details_sn_tv);
+ powerTv = itemView.findViewById(R.id.power_type_tv);
+ stateTv = itemView.findViewById(R.id.fragment_house_list_line_state_tv);
+ item_parent_rl = itemView.findViewById(R.id.item_parent_rl);
+ move_home_iv = itemView.findViewById(R.id.move_home_iv);
+ del_home_iv = itemView.findViewById(R.id.del_home_iv);
+ item_parent_swipeLayout = itemView.findViewById(R.id.item_parent_swipeLayout);
+ }
+ }
+
+ public interface OnClickListener {
+ void onClick(int position, DeviceBean deviceBean);
+
+ }
+}
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java b/app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java
index 0442ecb..b1f0c52 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.List;
+
public class HouseInfoAdapter extends RecyclerView.Adapter<HouseInfoAdapter.MyViewHolder> {
private List<HouseIdBean> mList;
@@ -202,9 +203,9 @@
public MyViewHolder(@NonNull View itemView) {
super(itemView);
- homeIconIv = itemView.findViewById(R.id.plant_details_image_iv);
- homeNameTv = itemView.findViewById(R.id.plant_details_name_tv);
- capacityTv = itemView.findViewById(R.id.plant_details_capacity_tv);
+ homeIconIv = itemView.findViewById(R.id.device_details_image_iv);
+ homeNameTv = itemView.findViewById(R.id.device_details_name_tv);
+ capacityTv = itemView.findViewById(R.id.device_details_sn_tv);
powerTv = itemView.findViewById(R.id.power_type_tv);
stateTv = itemView.findViewById(R.id.fragment_house_list_line_state_tv);
item_parent_rl = itemView.findViewById(R.id.item_parent_rl);
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/bean/CloudInverterDeviceBean.java b/app/src/main/java/com/hdl/photovoltaic/ui/bean/CloudInverterDeviceBean.java
index 378fd33..0b143be 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/bean/CloudInverterDeviceBean.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/bean/CloudInverterDeviceBean.java
@@ -32,7 +32,7 @@
private String inv;//inv鐘舵��
private int deviceStatus;//1:寰呮満,2:杩炴帴涓�,3:鏁呴殰,4:杩愯,5:绂荤嚎
- private String addresses;
+ private String addresses;//瀛愮綉鍙�/璁惧鍙�
private List<DeviceAttributeBean> status;
private String hwVersion;//杞欢鐗堟湰鍙�
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/bean/DeviceBean.java b/app/src/main/java/com/hdl/photovoltaic/ui/bean/DeviceBean.java
new file mode 100644
index 0000000..72f73f0
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/bean/DeviceBean.java
@@ -0,0 +1,78 @@
+package com.hdl.photovoltaic.ui.bean;
+
+import android.text.TextUtils;
+
+
+/**
+ * 璁惧锛堣处鍙蜂簯绔笂鎵�鏈夎澶囧垪琛級瀹炰綋瀵硅薄
+ */
+public class DeviceBean extends CloudInverterDeviceBean {
+
+
+ private String homeId;
+ private String homeName;
+ private String deviceType;//璁惧绫诲瀷(INV閫嗗彉鍣紝BMS鎺у埗鐩�,BATTERY鐢垫睜鍗曞厓)
+ private String outputActivePower;//閫嗗彉鍣ㄨ緭鍑烘湁鍔熷姛鐜�
+ private String address;//璇︾粏鍦板潃
+ private HouseInfoBean.Location location;//鐢电珯鍦板潃
+
+ public String getHomeId() {
+ return TextUtils.isEmpty(homeId) ? "" : homeId;
+ }
+
+ public void setHomeId(String homeId) {
+ this.homeId = homeId;
+ }
+
+ public String getHomeName() {
+ return TextUtils.isEmpty(homeName) ? "" : homeName;
+ }
+
+ public void setHomeName(String homeName) {
+ this.homeName = homeName;
+ }
+
+ public String getOutputActivePower() {
+ return TextUtils.isEmpty(outputActivePower) ? "" : outputActivePower;
+ }
+
+ public void setOutputActivePower(String outputActivePower) {
+ this.outputActivePower = outputActivePower;
+ }
+
+ public String getAddress() {
+ return TextUtils.isEmpty(address) ? "" : address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public HouseInfoBean.Location getLocation() {
+ return location;
+ }
+
+ public void setLocation(HouseInfoBean.Location location) {
+ this.location = location;
+ }
+
+ public String getDeviceType() {
+ return TextUtils.isEmpty(deviceType) ? "" : deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+ /**
+ * 鎷间綇瀹呭湴鍧�
+ *
+ * @return 浣忓畢鍦板潃
+ */
+ public String getHomeAddress() {
+ if (this.location == null) {
+ return this.address;
+ }
+ return this.location.getNationName() + this.location.getProvinceName() + this.location.getCityName() + this.address;
+ }
+
+}
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
index ae48a10..56b4f0c 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
@@ -1,25 +1,27 @@
package com.hdl.photovoltaic.ui.powerstation;
import android.Manifest;
-import android.content.Context;
import android.content.pm.PackageManager;
-import android.hardware.camera2.CameraManager;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
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.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.HomepageTitleTabSwitch;
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.other.HdlCommonLogic;
@@ -28,7 +30,9 @@
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.HouseIdBean;
import com.hdl.photovoltaic.uni.HDLUniMP;
import com.hdl.photovoltaic.utils.PermissionUtils;
@@ -42,14 +46,32 @@
import java.util.List;
/**
- * (浣忓畢)鐢电珯鍒楄〃-鐣岄潰
+ * 鐢电珯鍜岃澶�-鐣岄潰
*/
public class HouseListFragment extends CustomBaseFragment {
private FragmentHouseListBinding viewBinding;
private HouseInfoAdapter houseInfoAdapter;
- private CameraManager manager;
- private List<HouseIdBean> houseListBeanIDList = null;
+ private DeviceInfoAdapter deviceInfoAdapter;
+
+ private List<HouseIdBean> houseListBeanIDList;
+ private List<DeviceBean> deviceInfoList;
+
+
+ private int currentHouseListPage = 0; // 褰撳墠鐢电珯鍒楄〃椤电爜
+ private int currentHouseListTotal = 0; // 鐢电珯鍒楄〃鎬婚〉鐮�
+ private boolean isHouseLoadingMore = false; // 鏍囪鐢电珯鍒楄〃姝e湪鍔犺浇鏇村鏁版嵁
+
+ private int currentDeviceListPage = 0; // 褰撳墠璁惧鍒楄〃椤电爜
+ private int currentDeviceListTotal = 0; // 璁惧鍒楄〃鎬婚〉鐮�
+ private boolean isDeviceLoadingMore = false; // 鏍囪璁惧鍒楄〃姝e湪鍔犺浇鏇村鏁版嵁
+
+ private boolean isClickPowerStationLabel = true;//(鐢电珯鏍囩=true锛岃澶囨爣绛�=false)
+
+ private String key = SortValue.all;
+ private String value = SortValue.all;
+
+ private long pageSize = 20;//椤垫暟
@Override
@@ -60,7 +82,6 @@
@Override
public void onBindView(Bundle savedInstanceState) {
- manager = (CameraManager) _mActivity.getSystemService(Context.CAMERA_SERVICE);
initData();
//鍒濆鍖�
initView();
@@ -74,24 +95,32 @@
viewBinding.powerStationLabel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+ if (isClickPowerStationLabel) {
+ return;
+ }
+ isClickPowerStationLabel = true;
viewBinding.powerStationLabel.setTextAppearance(R.style.Text20Style);
viewBinding.deviceLabel.setTextAppearance(R.style.Text16Style);
viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);
viewBinding.deviceLabelParent.setVisibility(View.GONE);//璁惧鏍囩闅愯棌
+ loadNextPageHouseList(true, 1, true);
}
});
//璁惧鏍囩
viewBinding.deviceLabel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+ if (!isClickPowerStationLabel) {
+ 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);
-
-
+ loadNextPageDeviceList(true, 1, true);
}
});
@@ -103,12 +132,36 @@
}
});
- //璁剧疆涓嬫媺绠ご棰滆壊
+ //鐢电珯璁剧疆涓嬫媺绠ご棰滆壊
viewBinding.fragmentHouseSrl.setColorSchemeResources(R.color.text_FF245EC3);
+ //鐢电珯涓嬫媺璇诲彇
viewBinding.fragmentHouseSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
- downReadData(true);
+ viewBinding.fragmentHouseSrl.setRefreshing(false);
+ loadNextPageHouseList(true, 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, ++currentHouseListPage, false);
+ }
+ }
}
});
//杩涘叆鐢电珯璇︽儏,鍒犻櫎鐢电珯,绉诲姩鐢电珯浣嶇疆
@@ -140,7 +193,7 @@
HdlResidenceLogic.getInstance().moveHouseId(houseIdBean.getHomeId());
initData();//鍒濆鍖栫紦瀛樻暟鎹�
houseInfoAdapter.setList(houseListBeanIDList);//閲嶆柊鍒锋柊鍒楄〃
- nullDataUpdateUi(houseListBeanIDList);//妫�娴嬫暟鎹槸鍚︿负绌�
+ nullDataUpdateUi();//妫�娴嬫暟鎹槸鍚︿负绌�
}
@Override
@@ -218,40 +271,83 @@
viewBinding.stationNameRl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- viewBinding.stationNameRl.setSelected(!v.isSelected());
- viewBinding.stationNameIv.setSelected(viewBinding.stationNameRl.isSelected());
- }
- });
- //鐢电珯鍚嶇О绛涢��
- viewBinding.stationNameRl.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- viewBinding.stationNameRl.setSelected(!v.isSelected());
- viewBinding.stationNameIv.setSelected(viewBinding.stationNameRl.isSelected());
+ boolean isSelected = !v.isSelected();
+ viewBinding.stationNameRl.setSelected(isSelected);
+ viewBinding.stationNameIv.setSelected(isSelected);
+ key = SortType.homeNameSort;
+ value = isSelected ? SortValue.ascending : SortValue.descending;
}
});
//鍙戠數鍔熺巼绛涢��
viewBinding.stationPowerRl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- viewBinding.stationPowerRl.setSelected(!v.isSelected());
- viewBinding.stationPowerIv.setSelected(viewBinding.stationPowerRl.isSelected());
+ boolean isSelected = !v.isSelected();
+ viewBinding.stationPowerRl.setSelected(isSelected);
+ viewBinding.stationPowerIv.setSelected(isSelected);
+ key = SortType.powerSort;
+ value = isSelected ? SortValue.ascending : SortValue.descending;
}
});
//褰撴棩鍙戠數閲忕瓫閫�
viewBinding.stationDayRl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- viewBinding.stationDayRl.setSelected(!v.isSelected());
- viewBinding.stationDayIv.setSelected(viewBinding.stationDayRl.isSelected());
+ boolean isSelected = !v.isSelected();
+ viewBinding.stationDayRl.setSelected(isSelected);
+ viewBinding.stationDayIv.setSelected(isSelected);
+ key = SortType.todayElectricitySort;
+ value = isSelected ? SortValue.ascending : SortValue.descending;
}
});
//褰撴湀鍙戠數閲忕瓫閫�
viewBinding.stationMonthRl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- viewBinding.stationMonthRl.setSelected(!v.isSelected());
- viewBinding.stationMonthIv.setSelected(viewBinding.stationMonthRl.isSelected());
+ boolean isSelected = !v.isSelected();
+ viewBinding.stationMonthRl.setSelected(isSelected);
+ viewBinding.stationMonthIv.setSelected(isSelected);
+ key = SortType.monthElectricitySort;
+ value = isSelected ? SortValue.ascending : SortValue.descending;
+ }
+ });
+ //鐐瑰嚮璁惧
+ 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) {
+ 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);
+ }
+ }
}
});
@@ -260,20 +356,30 @@
private void initView() {
viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);
viewBinding.deviceLabelParent.setVisibility(View.GONE);
-
- LinearLayoutManager linearLayout = new LinearLayoutManager(_mActivity);
+ //鐢电珯鏍囩
houseInfoAdapter = new HouseInfoAdapter(_mActivity);
- viewBinding.fragmentHouseSrlListRc.setLayoutManager(linearLayout);
+ viewBinding.fragmentHouseSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
viewBinding.fragmentHouseSrlListRc.setAdapter(houseInfoAdapter);
houseInfoAdapter.setList(this.houseListBeanIDList);
- this.nullDataUpdateUi(houseListBeanIDList);
+
+ //璁惧鏍囩
+ deviceInfoAdapter = new DeviceInfoAdapter(_mActivity);
+ viewBinding.fragmentDeviceSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
+ viewBinding.fragmentDeviceSrlListRc.setAdapter(deviceInfoAdapter);
+ this.nullDataUpdateUi();
}
private void initData() {
- this.houseListBeanIDList = new ArrayList<>();
- this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList());
+ if (isClickPowerStationLabel) {
+ this.houseListBeanIDList = new ArrayList<>();
+ this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList());
+ } else {
+ this.deviceInfoList = new ArrayList<>();
+ this.deviceInfoList.add(new DeviceBean());
+// this.deviceInfoList.addAll(HdlDeviceLogic.getInstance().getListDevice());
+ }
}
/**
@@ -287,7 +393,7 @@
if (HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL.equals(eventBus.getTopic())) {
if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
//uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
- downReadData(false);
+ loadNextPageHouseList(false, 1, true);
if (eventBus.getData() != null) {
Gson gson = new Gson();
String json = eventBus.getData().toString();
@@ -326,7 +432,7 @@
if (MqttRecvClient.getInstance() != null) {
MqttRecvClient.getInstance().removeAllTopic();
}
- downReadData(false);
+ loadNextPageHouseList(false, 1, true);
} else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) {
//杩涘幓浣忓畢璇︽儏uni璇诲彇閫嗗彉鍣ㄥ垪琛ㄦ垚鍔熷悗閫氱煡
@@ -341,41 +447,55 @@
//鎺ユ敹澶栭儴鐐瑰嚮浜嬩欢
if (eventBus.getType().equals(HomepageTitleTabSwitch.powerstation.toString())) {
HdlLogLogic.print("姝e湪鐐瑰嚮銆愮數绔欍��");
- initData();//鍒濆鍖栫紦瀛樻暟鎹�
- houseInfoAdapter.setList(houseListBeanIDList);//閲嶆柊鍒锋柊鍒楄〃
+ loadNextPageHouseList(true, 1, true);
}
}
}
/**
- * 鍒锋柊UI
+ * 鍒锋柊UI锛堢數绔欙級
*
* @param isRefreshing 琛ㄧず鏄笅鎷夊埛鏂扮殑
*/
- private void downReadData(boolean isRefreshing) {
+ private void loadNextPageHouseList(boolean isRefreshing, long pageNo, boolean isClear) {
+ if (isClear) {
+ clearData();
+ }
+ //绗竴椤佃鍙栨暟鎹己鍒惰鍙�
+ if (pageNo > 1 && currentHouseListPage > currentHouseListTotal) {
+ --currentHouseListPage;
+ //褰撳墠椤典笉鑳藉ぇ浜庢�婚〉鏁�
+ return;
+ }
+ isHouseLoadingMore = true;//鏍囪璇诲彇鐘舵��
+ if (isRefreshing) {
+ showLoading();
+ }
+
//鑾峰彇浣忓畢(鐢电珯)ID鍒楄〃
- HdlResidenceLogic.getInstance().getResidenceIdList("", "", new CloudCallBeak<List<HouseIdBean>>() {
+ HdlResidenceLogic.getInstance().getResidenceIdList(key, value, pageNo, pageSize, new CloudCallBeak<HdlResidenceLogic.HouseBeanClass>() {
@Override
- public void onSuccess(List<HouseIdBean> list) {
+ public void onSuccess(HdlResidenceLogic.HouseBeanClass houseBeanClass) {
HdlThreadLogic.runMainThread(new Runnable() {
@Override
public void run() {
if (isRefreshing) {
- //鍏抽棴涓嬫媺鍒锋柊鐨勫湀鍦�
- viewBinding.fragmentHouseSrl.setRefreshing(false);
+ hideLoading();
}
- if (list != null && list.size() > 0) {
+ isHouseLoadingMore = false;
+ if (houseBeanClass != null) {
+ currentHouseListTotal = (int) houseBeanClass.getTotalPage();
+ currentHouseListPage = (int) houseBeanClass.getPageNo();
//鏇存柊缂撳瓨
- HdlResidenceLogic.getInstance().setHouseIdList(list);
+ HdlResidenceLogic.getInstance().setHouseIdList(houseBeanClass.getList());
if (houseInfoAdapter != null) {
initData();
//鏇存柊UI
houseInfoAdapter.setList(houseListBeanIDList);
}
-
}
- nullDataUpdateUi(list);
+ nullDataUpdateUi();
}
}, _mActivity, ShowErrorMode.YES);
@@ -386,9 +506,12 @@
HdlThreadLogic.runMainThread(new Runnable() {
@Override
public void run() {
+ if (currentHouseListPage > 1) {
+ --currentHouseListPage;
+ }
+ isHouseLoadingMore = false;
if (isRefreshing) {
- //鍏抽棴涓嬫媺鍒锋柊鐨勫湀鍦�
- viewBinding.fragmentHouseSrl.setRefreshing(false);
+ hideLoading();
}
}
@@ -397,6 +520,166 @@
});
}
+ /**
+ * 鍒锋柊UI锛堣澶囷級
+ *
+ * @param isRefreshing 琛ㄧず鏄笅鎷夊埛鏂扮殑
+ * @param pageNo 椤电爜
+ * @param isClear true琛ㄧず娓呯┖缂撳瓨
+ */
+ private void loadNextPageDeviceList(boolean isRefreshing, long pageNo, boolean isClear) {
+ if (isClear) {
+ clearData();
+ }
+ //绗竴椤佃鍙栨暟鎹己鍒惰鍙�
+ if (pageNo > 1 && currentDeviceListPage > currentDeviceListTotal) {
+ --currentDeviceListPage;
+ //褰撳墠椤典笉鑳藉ぇ浜庢�婚〉鏁�
+ return;
+ }
+ isDeviceLoadingMore = true;//鏍囪璇诲彇鐘舵��
+ if (isRefreshing) {
+ showLoading();
+ }
+ //鑾峰彇浣忓畢(鐢电珯)ID鍒楄〃
+ HdlDeviceLogic.getInstance().getPowerStationDeviceList("", pageNo, pageSize, new CloudCallBeak<PageNumberObject<DeviceBean>>() {
+ @Override
+ public void onSuccess(PageNumberObject<DeviceBean> pageNumberObject) {
+ HdlThreadLogic.runMainThread(new Runnable() {
+ @Override
+ public void run() {
+ if (isRefreshing) {
+ hideLoading();
+ }
+ isDeviceLoadingMore = false;
+ if (pageNumberObject != null) {
+ currentDeviceListTotal = (int) pageNumberObject.getTotalPage();
+ currentDeviceListPage = (int) pageNumberObject.getPageNo();
+ //鏇存柊缂撳瓨
+ HdlDeviceLogic.getInstance().setListDevice(pageNumberObject.getList());
+ //鏇存柊缂撳瓨
+ if (deviceInfoAdapter != null) {
+ initData();
+ //鏇存柊UI
+ deviceInfoAdapter.setList(deviceInfoList);
+ }
+ }
+ nullDataUpdateUi();
+ }
+ }, _mActivity, ShowErrorMode.YES);
+
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ HdlThreadLogic.runMainThread(new Runnable() {
+ @Override
+ public void run() {
+ if (currentDeviceListPage > 1) {
+ --currentDeviceListPage;
+ }
+ isDeviceLoadingMore = false;
+ if (isRefreshing) {
+ hideLoading();
+ }
+
+ }
+ }, _mActivity, ShowErrorMode.YES);
+ }
+ });
+ }
+
+
+ /**
+ * 娓呯┖缂撳瓨鏁版嵁
+ */
+ private void clearData() {
+ if (isClickPowerStationLabel) {
+ currentHouseListPage = 0;// 閲嶇疆褰撳墠鐢电珯鍒楄〃椤电爜
+ currentHouseListTotal = 0;// 閲嶇疆褰撳墠鐢电珯鍒楄〃鎬婚〉鐮�
+ if (houseListBeanIDList != null) {
+ houseListBeanIDList.clear(); //娓呯┖涓存椂缂撳瓨鍒楄〃
+ }
+ HdlResidenceLogic.getInstance().clearHouseList(); //琛ㄧず寮哄埗娓呯┖鎵�鏈夌紦瀛樹俊鎭�
+ } else {
+ currentDeviceListPage = 0; // 閲嶇疆褰撳墠璁惧鍒楄〃椤电爜
+ currentDeviceListTotal = 0; // 閲嶇疆璁惧鍒楄〃鎬婚〉鐮�
+ if (deviceInfoList != null) {
+ deviceInfoList.clear();//娓呯┖涓存椂缂撳瓨鍒楄〃
+ }
+ HdlDeviceLogic.getInstance().clearDeviceList(); //琛ㄧず寮哄埗娓呯┖鎵�鏈夌紦瀛樹俊鎭�
+ }
+ }
+
+
+ /**
+ * 娌℃湁鐢电珯鍒楄〃鐨勬牱寮�
+ */
+ private void nullDataUpdateUi() {
+ boolean is_data;
+ if (isClickPowerStationLabel) {
+ is_data = houseListBeanIDList != null && houseListBeanIDList.size() > 0;
+ } else {
+ is_data = deviceInfoList != null && deviceInfoList.size() > 0;
+ }
+ HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.nullDataIc.getRoot(), viewBinding.nullDataIc.nullDataGifAnimationIv, viewBinding.nullDataIc.nullDataTv, getString(R.string.my_power_station_data_null), is_data);
+ }
+
+ /**
+ * 鍒犻櫎鐢电珯,閫嗗彉鍣�
+ * (寮�濮嬪垹闄ょ數绔欙紝鍚屾椂锛屽悜閫嗗彉鍣ㄥ彂閫佸垵濮嬪寲閫嗗彉鍣ㄦ寚浠�,鏃犻』澶勭悊缁撴灉)
+ *
+ * @param list 璁惧鍒楄〃
+ */
+ private void initializeInverter(List<GatewayBean> list) {
+ if (list == null || list.size() == 0) {
+ return;
+ }
+ for (int i = 0; i < list.size(); i++) {
+ GatewayBean gatewayBean = list.get(i);
+ HdlDeviceLogic.getInstance().initializeGateway(gatewayBean.getDevice_mac(), new LinkCallBack<Boolean>() {
+ @Override
+ public void onSuccess(Boolean obj) {
+// HdlLogLogic.print("鍒濆鍖栭�嗗彉鍣ㄦ垚鍔�-->mac:" + cloudInverterDeviceBean.getOsn(),true);
+ }
+
+ @Override
+ public void onError(HDLLinkException e) {
+// HdlLogLogic.print("鍒濆鍖栭�嗗彉鍣ㄥけ璐�-->mac:" + cloudInverterDeviceBean.getOsn(),true);
+ }
+ });
+ }
+ }
+
+ /**
+ * 鍒犻櫎鐢电珯
+ *
+ * @param homeId 鐢电珯id
+ * @param list 閫嗗彉鍣ㄥ垪琛�
+ */
+ private void deleteResidence(String homeId, List<GatewayBean> list) {
+
+ //鍒犻櫎浣忓畢
+ HdlResidenceLogic.getInstance().delResidence(homeId, new CloudCallBeak<Boolean>() {
+ @Override
+ public void onSuccess(Boolean obj) {
+ hideLoading();
+ //鍙戣捣鍒濆鍖栨寚浠ょ粰閫嗗彉鍣�;
+ initializeInverter(list);
+ HdlResidenceLogic.getInstance().delHouseId(homeId);
+ initData();//鍒濆鍖栫紦瀛樻暟鎹�
+ houseInfoAdapter.setList(houseListBeanIDList);//閲嶆柊鍒锋柊鍒楄〃
+ nullDataUpdateUi();//妫�娴嬫暟鎹槸鍚︿负绌�
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ hideLoading();
+
+ HdlThreadLogic.toast(_mActivity, e);
+ }
+ });
+ }
/**
* 鐢宠鏉冮檺
@@ -446,69 +729,6 @@
void failing();
- }
-
- /**
- * 娌℃湁鐢电珯鍒楄〃鐨勬牱寮�
- */
- 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 list 璁惧鍒楄〃
- */
- private void initializeInverter(List<GatewayBean> list) {
- if (list == null || list.size() == 0) {
- return;
- }
- for (int i = 0; i < list.size(); i++) {
- GatewayBean gatewayBean = list.get(i);
- HdlDeviceLogic.getInstance().initializeGateway(gatewayBean.getDevice_mac(), new LinkCallBack<Boolean>() {
- @Override
- public void onSuccess(Boolean obj) {
-// HdlLogLogic.print("鍒濆鍖栭�嗗彉鍣ㄦ垚鍔�-->mac:" + cloudInverterDeviceBean.getOsn(),true);
- }
-
- @Override
- public void onError(HDLLinkException e) {
-// HdlLogLogic.print("鍒濆鍖栭�嗗彉鍣ㄥけ璐�-->mac:" + cloudInverterDeviceBean.getOsn(),true);
- }
- });
- }
- }
-
- /**
- * 鍒犻櫎鐢电珯
- *
- * @param homeId 鐢电珯id
- * @param list 閫嗗彉鍣ㄥ垪琛�
- */
- private void deleteResidence(String homeId, List<GatewayBean> list) {
-
- //鍒犻櫎浣忓畢
- HdlResidenceLogic.getInstance().delResidence(homeId, new CloudCallBeak<Boolean>() {
- @Override
- public void onSuccess(Boolean obj) {
- hideLoading();
- //鍙戣捣鍒濆鍖栨寚浠ょ粰閫嗗彉鍣�;
- initializeInverter(list);
- HdlResidenceLogic.getInstance().delHouseId(homeId);
- initData();//鍒濆鍖栫紦瀛樻暟鎹�
- houseInfoAdapter.setList(houseListBeanIDList);//閲嶆柊鍒锋柊鍒楄〃
- nullDataUpdateUi(houseListBeanIDList);//妫�娴嬫暟鎹槸鍚︿负绌�
- }
-
- @Override
- public void onFailure(HDLException e) {
- hideLoading();
-
- HdlThreadLogic.toast(_mActivity, e);
- }
- });
}
diff --git a/app/src/main/res/drawable/device_image.png b/app/src/main/res/drawable/device_image.png
new file mode 100644
index 0000000..24446dc
--- /dev/null
+++ b/app/src/main/res/drawable/device_image.png
Binary files differ
diff --git a/app/src/main/res/layout/activity_my_power_station.xml b/app/src/main/res/layout/activity_my_power_station.xml
index f359a9d..c4ff53b 100644
--- a/app/src/main/res/layout/activity_my_power_station.xml
+++ b/app/src/main/res/layout/activity_my_power_station.xml
@@ -5,7 +5,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bj"
-
tools:context="com.hdl.photovoltaic.ui.MyPowerStationActivity">
<!--棣栭〉-Fragment-->
diff --git a/app/src/main/res/layout/item_device_details.xml b/app/src/main/res/layout/item_device_details.xml
new file mode 100644
index 0000000..c3b8f3e
--- /dev/null
+++ b/app/src/main/res/layout/item_device_details.xml
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.hdl.photovoltaic.widget.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/item_parent_swipeLayout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <include
+ android:id="@+id/swipe_layout_il"
+ layout="@layout/swipe_right_layout" />
+
+ <RelativeLayout
+ android:id="@+id/item_parent_rl"
+ android:layout_width="match_parent"
+ android:layout_height="164dp">
+
+ <RelativeLayout
+ android:id="@+id/device_details_info_rl"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginStart="@dimen/dp_16"
+ android:layout_marginTop="@dimen/dp_16"
+ android:layout_marginEnd="@dimen/dp_16"
+ android:background="@drawable/ffffff_13">
+
+ <ImageView
+ android:id="@+id/device_details_image_iv"
+ android:layout_width="44dp"
+ android:layout_height="42dp"
+ android:layout_marginStart="@dimen/dp_16"
+ android:layout_marginTop="@dimen/dp_13"
+ android:background="@drawable/device_image"
+ android:scaleType="centerCrop" />
+
+ <TextView
+ android:id="@+id/device_details_name_tv"
+ android:layout_width="170dp"
+ android:layout_height="@dimen/dp_19"
+ android:layout_marginStart="@dimen/dp_11"
+ android:layout_marginTop="@dimen/dp_15"
+ android:layout_toEndOf="@+id/device_details_image_iv"
+ android:ellipsize="end"
+ android:gravity="center_vertical|start"
+ android:singleLine="true"
+ android:textColor="@color/text_90000000"
+ android:textSize="@dimen/text_16"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/device_details_sn_tv"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/dp_17"
+ android:layout_below="@+id/device_details_name_tv"
+ android:layout_alignStart="@+id/device_details_name_tv"
+ android:layout_marginTop="@dimen/dp_3"
+ android:gravity="center_vertical"
+ android:textColor="@color/text_40000000"
+ android:textSize="@dimen/text_12" />
+
+ <LinearLayout
+ android:id="@+id/screening_condition_ll"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/dp_36"
+ android:layout_below="@+id/device_details_image_iv"
+ android:layout_marginStart="@dimen/dp_16"
+ android:layout_marginTop="@dimen/dp_17"
+ android:orientation="horizontal">
+
+ <LinearLayout
+ android:id="@+id/power_ll"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/power_value_tv"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:text="99"
+ android:textColor="@color/text_90000000"
+ android:textSize="@dimen/text_15"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/power_type_tv"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/dp_15"
+ android:layout_marginTop="3dp"
+ android:gravity="center"
+ android:text="@string/generated_power"
+ android:textColor="@color/text_40000000"
+ android:textSize="@dimen/text_12" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/day_ll"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/day_value_tv"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/dp_18"
+ android:gravity="center"
+ android:text="99"
+ android:textColor="@color/text_90000000"
+ android:textSize="@dimen/text_15"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/day_type_tv"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/dp_15"
+ android:layout_marginTop="3dp"
+ android:gravity="center"
+ android:text="@string/day_power_generation"
+ android:textColor="@color/text_40000000"
+ android:textSize="@dimen/text_12" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/month_ll"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/month_value_tv"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/dp_18"
+ android:gravity="center"
+ android:text="99"
+ android:textColor="@color/text_90000000"
+ android:textSize="@dimen/text_15"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/month_type_tv"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/dp_15"
+ android:layout_marginTop="3dp"
+ android:gravity="center"
+ android:text="@string/month_power_generation"
+ android:textColor="@color/text_40000000"
+ android:textSize="@dimen/text_12" />
+
+ </LinearLayout>
+
+
+ </LinearLayout>
+
+ <View
+ android:id="@+id/line"
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:layout_below="@+id/screening_condition_ll"
+ android:layout_marginStart="@dimen/dp_17"
+ android:layout_marginTop="@dimen/dp_8"
+ android:layout_marginEnd="@dimen/dp_16"
+ android:background="@color/text_E1E1E1" />
+
+ <ImageView
+ android:id="@+id/plant_details_location_iv"
+ android:layout_width="@dimen/dp_19"
+ android:layout_height="@dimen/dp_19"
+ android:layout_below="@+id/line"
+ android:layout_marginStart="@dimen/dp_11"
+ android:layout_marginTop="@dimen/dp_7"
+ android:src="@drawable/location" />
+
+ <TextView
+ android:id="@+id/plant_details_location_tv"
+ android:layout_width="290dp"
+ android:layout_height="@dimen/dp_19"
+ android:layout_below="@+id/line"
+ android:layout_marginStart="@dimen/dp_3"
+ android:layout_marginTop="@dimen/dp_8"
+ android:layout_toEndOf="@+id/plant_details_location_iv"
+ android:ellipsize="end"
+ android:gravity="center_vertical|start"
+ android:singleLine="true"
+ android:text="@string/power_station"
+ android:textColor="@color/text_40000000"
+ android:textSize="@dimen/text_12" />
+
+ <TextView
+ android:id="@+id/fragment_house_list_line_state_tv"
+ android:layout_width="69dp"
+ android:layout_height="@dimen/dp_33"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentEnd="true"
+ android:background="@drawable/state_ffb300"
+ android:gravity="center"
+ android:text="@string/my_power_station_connecting"
+ android:textColor="@color/text_FFFFFFFF"
+ android:textSize="@dimen/text_12" />
+
+
+ </RelativeLayout>
+
+
+ </RelativeLayout>
+
+</com.hdl.photovoltaic.widget.SwipeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_plant_details.xml b/app/src/main/res/layout/item_plant_details.xml
index 9c91e74..2682a41 100644
--- a/app/src/main/res/layout/item_plant_details.xml
+++ b/app/src/main/res/layout/item_plant_details.xml
@@ -15,7 +15,7 @@
android:layout_height="164dp">
<RelativeLayout
- android:id="@+id/plant_details_info_rl"
+ android:id="@+id/device_details_info_rl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/dp_16"
@@ -24,7 +24,7 @@
android:background="@drawable/ffffff_13">
<ImageView
- android:id="@+id/plant_details_image_iv"
+ android:id="@+id/device_details_image_iv"
android:layout_width="44dp"
android:layout_height="42dp"
android:layout_marginStart="@dimen/dp_16"
@@ -33,12 +33,12 @@
android:scaleType="centerCrop" />
<TextView
- android:id="@+id/plant_details_name_tv"
+ android:id="@+id/device_details_name_tv"
android:layout_width="170dp"
android:layout_height="@dimen/dp_19"
android:layout_marginStart="@dimen/dp_11"
android:layout_marginTop="@dimen/dp_15"
- android:layout_toEndOf="@+id/plant_details_image_iv"
+ android:layout_toEndOf="@+id/device_details_image_iv"
android:ellipsize="end"
android:gravity="center_vertical|start"
android:singleLine="true"
@@ -48,11 +48,11 @@
android:textStyle="bold" />
<TextView
- android:id="@+id/plant_details_capacity_tv"
+ android:id="@+id/device_details_sn_tv"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_17"
- android:layout_below="@+id/plant_details_name_tv"
- android:layout_alignStart="@+id/plant_details_name_tv"
+ android:layout_below="@+id/device_details_name_tv"
+ android:layout_alignStart="@+id/device_details_name_tv"
android:layout_marginTop="@dimen/dp_3"
android:gravity="center_vertical"
android:text="@string/installed_capacity"
@@ -63,7 +63,7 @@
android:id="@+id/screening_condition_ll"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_36"
- android:layout_below="@+id/plant_details_image_iv"
+ android:layout_below="@+id/device_details_image_iv"
android:layout_marginStart="@dimen/dp_16"
android:layout_marginTop="@dimen/dp_17"
android:orientation="horizontal">
--
Gitblit v1.8.0