From 0a18a8180bc6040c941b07df1be1f7b726b4c155 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期一, 21 八月 2023 14:19:26 +0800
Subject: [PATCH] Merge branch 'master' into wjc
---
app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java | 203 +++++++++++++++++++++++++-------------------------
1 files changed, 103 insertions(+), 100 deletions(-)
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 54a63fe..73e33cb 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
@@ -1,22 +1,28 @@
package com.hdl.photovoltaic.other;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.text.TextUtils;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
+import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.photovoltaic.bean.HttpResponsePack;
import com.hdl.photovoltaic.config.UserConfigManage;
import com.hdl.photovoltaic.internet.HttpClient;
import com.hdl.photovoltaic.internet.api.HttpApi;
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.HouseInfoBean;
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
import com.hdl.sdk.link.common.exception.HDLLinkException;
import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
import com.hdl.sdk.link.core.callback.GatewayCallBack;
import com.hdl.sdk.link.core.config.HDLLinkConfig;
+import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -126,12 +132,12 @@
}
@Override
- public void onFailure(Exception exception) {
+ public void onFailure(HDLException e) {
atomicInteger.set(atomicInteger.get() + 1);
if (atomicInteger.get() == houseIdList.size()) {
//鏈�鍚庝竴鏉¢��鍑�
if (cloudCallBeak != null) {
- cloudCallBeak.onFailure(exception);
+ cloudCallBeak.onFailure(e);
}
}
}
@@ -146,9 +152,9 @@
}
@Override
- public void onFailure(Exception exception) {
+ public void onFailure(HDLException e) {
if (cloudCallBeak != null) {
- cloudCallBeak.onFailure(exception);
+ cloudCallBeak.onFailure(e);
}
}
});
@@ -158,8 +164,11 @@
/**
* 鑾峰彇浣忓畢(鐢电珯)ID鍒楄〃
*
- * @param key 鍙戠數鍔熺巼鎺掑簭(powerSort);浠婃棩鍙戠數閲忔帓搴�(todayElectricitySort);鍒涘缓鏃堕棿鎺掑簭(createTimeSort);
- * @param keyValue (descending:闄嶅簭ascending:鍗囧簭),
+ * @param key 鍙戠數鍔熺巼鎺掑簭(powerSort);
+ * 浠婃棩鍙戠數閲忔帓搴�(todayElectricitySort);
+ * 鍒涘缓鏃堕棿鎺掑簭(createTimeSort);
+ * @param keyValue (descending:闄嶅簭
+ * ascending:鍗囧簭),
*/
public void getResidenceIdList(String key, String keyValue, CloudCallBeak<List<HouseIdBean>> cloudCallBeak) {
@@ -168,72 +177,66 @@
if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(keyValue)) {
json.addProperty(key, keyValue);//鍙戠數鍔熺巼鎺掑簭(descending:闄嶅簭ascending:鍗囧簭)
}
-// json.addProperty("powerSort", "descending");//鍙戠數鍔熺巼鎺掑簭(descending:闄嶅簭ascending:鍗囧簭)
-// json.addProperty("todayElectricitySort", "descending");//浠婃棩鍙戠數閲忔帓搴�
-// json.addProperty("createTimeSort", "descending");//鍒涘缓鏃堕棿鎺掑簭
// json.addProperty("zoneType", "password");//鍖哄煙
json.addProperty("pageNo", 1);//椤电爜
json.addProperty("pageSize", pageSize);//椤垫暟
List<HouseIdBean> list = new ArrayList<>();
- HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
+ HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
@Override
- public void onSuccess(HttpResponsePack httpResponsePack) {
- if (httpResponsePack != null && httpResponsePack.getData() != null) {
- Gson gson = new Gson();
- String jsonStr = gson.toJson(httpResponsePack.getData());
- HouseBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseBeanClass.class);
- list.addAll(houseInfoBeanClass.getList());
- //鎬诲叡鏈夊灏戦〉
- long totalPage = houseInfoBeanClass.totalPage;
- if (totalPage < 2) {
- if (cloudCallBeak != null) {
- cloudCallBeak.onSuccess(list);
- }
- return;
- }
- //璁板綍璇锋眰鏉℃暟
- AtomicInteger atomicInteger = new AtomicInteger(0);
- //浠庣浜岄〉鑾峰彇鏁版嵁
- for (int i = 2; i <= totalPage; i++) {
- json.addProperty("pageNo", i);//鏇存柊椤电爜
- HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
- @Override
- public void onSuccess(HttpResponsePack httpResponsePack) {
- atomicInteger.set(atomicInteger.get() + 1);
- Gson gson = new Gson();
- String jsonStr = gson.toJson(httpResponsePack.getData());
- HouseBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseBeanClass.class);
- list.addAll(houseInfoBeanClass.getList());
- if (atomicInteger.get() == totalPage - 1) {
- //鏈�鍚庝竴鏉¢��鍑�
- if (cloudCallBeak != null) {
- cloudCallBeak.onSuccess(list);
- }
- }
- }
-
- @Override
- public void onFailure(Exception exception) {
- atomicInteger.set(atomicInteger.get() + 1);
- if (atomicInteger.get() == totalPage - 1) {
- //鏈�鍚庝竴鏉¢��鍑�
- if (cloudCallBeak != null) {
- cloudCallBeak.onSuccess(list);
- }
- }
- }
- });
- }
-
- } else {
+ public void onSuccess(String jsonStr) {
+ if (TextUtils.isEmpty(jsonStr)) {
if (cloudCallBeak != null) {
cloudCallBeak.onSuccess(list);
}
}
+ Gson gson = new Gson();
+ HouseBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseBeanClass.class);
+ list.addAll(houseInfoBeanClass.getList());
+ //鎬诲叡鏈夊灏戦〉
+ long totalPage = houseInfoBeanClass.totalPage;
+ if (totalPage < 2) {
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(list);
+ }
+ return;
+ }
+ //璁板綍璇锋眰鏉℃暟
+ AtomicInteger atomicInteger = new AtomicInteger(0);
+ //浠庣浜岄〉鑾峰彇鏁版嵁
+ for (int i = 2; i <= totalPage; i++) {
+ json.addProperty("pageNo", i);//鏇存柊椤电爜
+ HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
+ @Override
+ public void onSuccess(String jsonStr) {
+ atomicInteger.set(atomicInteger.get() + 1);
+ Gson gson = new Gson();
+ HouseBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseBeanClass.class);
+ list.addAll(houseInfoBeanClass.getList());
+ if (atomicInteger.get() == totalPage - 1) {
+ //鏈�鍚庝竴鏉¢��鍑�
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(list);
+ }
+ }
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ atomicInteger.set(atomicInteger.get() + 1);
+ if (atomicInteger.get() == totalPage - 1) {
+ //鏈�鍚庝竴鏉¢��鍑�
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(list);
+ }
+ }
+ }
+ });
+ }
+
}
@Override
- public void onFailure(Exception exception) {
+ public void onFailure(HDLException exception) {
if (cloudCallBeak != null) {
cloudCallBeak.onFailure(exception);
}
@@ -254,24 +257,25 @@
JsonObject json = new JsonObject();
json.addProperty("homeId", homeId);//鐢电珯id
//json.addProperty("zoneType", "password");//鍖哄煙
- HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
+ HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
@Override
- public void onSuccess(HttpResponsePack httpResponsePack) {
- if (httpResponsePack != null && httpResponsePack.getData() != null) {
- Gson gson = new Gson();
- String jsonStr = gson.toJson(httpResponsePack.getData());
- HouseInfoBean houseInfoBean = gson.fromJson(jsonStr, HouseInfoBean.class);
-
+ public void onSuccess(String jsonStr) {
+ if (TextUtils.isEmpty(jsonStr)) {
if (cloudCallBeak != null) {
- cloudCallBeak.onSuccess(houseInfoBean);
+ cloudCallBeak.onSuccess(null);
}
+ }
+ Gson gson = new Gson();
+ HouseInfoBean houseInfoBean = gson.fromJson(jsonStr, HouseInfoBean.class);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(houseInfoBean);
}
}
@Override
- public void onFailure(Exception exception) {
+ public void onFailure(HDLException e) {
if (cloudCallBeak != null) {
- cloudCallBeak.onFailure(exception);
+ cloudCallBeak.onFailure(e);
}
}
});
@@ -311,9 +315,9 @@
json.addProperty("electrovalence", houseInfoBean.getElectrovalence());
json.addProperty("totalCost", houseInfoBean.getTotalCost());
json.addProperty("zoneType", houseInfoBean.getZoneType());
- HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
+ HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
@Override
- public void onSuccess(HttpResponsePack httpResponsePack) {
+ public void onSuccess(String str) {
if (cloudCallBeak != null) {
cloudCallBeak.onSuccess(true);
}
@@ -321,9 +325,9 @@
}
@Override
- public void onFailure(Exception exception) {
+ public void onFailure(HDLException e) {
if (cloudCallBeak != null) {
- cloudCallBeak.onFailure(exception);
+ cloudCallBeak.onFailure(e);
}
}
});
@@ -340,9 +344,9 @@
JsonObject json = new JsonObject();
json.addProperty("homeId", homeId);//鐢电珯id
//json.addProperty("zoneType", "password");//鍖哄煙
- HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
+ HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
@Override
- public void onSuccess(HttpResponsePack httpResponsePack) {
+ public void onSuccess(String str) {
if (cloudCallBeak != null) {
cloudCallBeak.onSuccess(true);
}
@@ -350,9 +354,9 @@
}
@Override
- public void onFailure(Exception exception) {
+ public void onFailure(HDLException e) {
if (cloudCallBeak != null) {
- cloudCallBeak.onFailure(exception);
+ cloudCallBeak.onFailure(e);
}
}
});
@@ -390,9 +394,9 @@
json.addProperty("electrovalence", houseInfoBean.getElectrovalence());
json.addProperty("totalCost", houseInfoBean.getTotalCost());
json.addProperty("zoneType", houseInfoBean.getZoneType());
- HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
+ HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
@Override
- public void onSuccess(HttpResponsePack httpResponsePack) {
+ public void onSuccess(String str) {
if (cloudCallBeak != null) {
cloudCallBeak.onSuccess(true);
}
@@ -400,9 +404,9 @@
}
@Override
- public void onFailure(Exception exception) {
+ public void onFailure(HDLException e) {
if (cloudCallBeak != null) {
- cloudCallBeak.onFailure(exception);
+ cloudCallBeak.onFailure(e);
}
}
});
@@ -413,28 +417,28 @@
/**
* 鑾峰彇浣忓畢鍥剧墖
*/
- public void getResidenceImage(String imageUrl, CloudCallBeak<List<HouseIdBean>> cloudCallBeak) {
+ public void getResidenceImage(String imageUrl, CloudCallBeak<Bitmap> cloudCallBeak) {
String requestUrl = imageUrl;
JsonObject json = new JsonObject();
- List<HouseIdBean> list = new ArrayList<>();
- HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
+ HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
@Override
- public void onSuccess(HttpResponsePack httpResponsePack) {
- if (httpResponsePack != null && httpResponsePack.getData() != null) {
- Gson gson = new Gson();
- String jsonStr = gson.toJson(httpResponsePack.getData());
- HouseBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseBeanClass.class);
- } else {
+ public void onSuccess(String jsonStr) {
+ if (TextUtils.isEmpty(jsonStr)) {
if (cloudCallBeak != null) {
- cloudCallBeak.onSuccess(list);
+ cloudCallBeak.onSuccess(null);
}
+ return;
+ }
+ Bitmap bitmap = BitmapFactory.decodeByteArray(jsonStr.getBytes(), 0, jsonStr.getBytes().length);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(bitmap);
}
}
@Override
- public void onFailure(Exception exception) {
+ public void onFailure(HDLException e) {
if (cloudCallBeak != null) {
- cloudCallBeak.onFailure(exception);
+ cloudCallBeak.onFailure(e);
}
}
});
@@ -510,9 +514,9 @@
*/
public void switchHouse(HouseIdBean houseIdBean) {
String oidHomeId = UserConfigManage.getInstance().getHomeId();
- if (houseIdBean.getHomeId().equals(oidHomeId)) {
- return;
- }
+// if (houseIdBean.getHomeId().equals(oidHomeId)) {
+// return;
+// }
//鍒犻櫎鏃х殑浣忓畢鏂囦欢澶�
HdlFileLogic.getInstance().deleteDirectory(HdlFileLogic.getInstance().getCurrentHomeRootPath());
//閲嶆柊璁剧疆浣忓畢id
@@ -526,16 +530,14 @@
HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() {
@Override
public void onSuccess(List<GatewayBean> gatewayBeanList) {
-
}
@Override
public void onError(HDLLinkException e) {
-
}
});
-
}
+
/**
* 閰嶇疆鏈湴閫氫俊鐨勪俊鎭�(tcp閫氫俊鐢ㄥ埌)
@@ -544,6 +546,7 @@
HDLLinkConfig.getInstance().setHomeId(UserConfigManage.getInstance().getHomeId());
HDLLinkConfig.getInstance().setLocalSecret(UserConfigManage.getInstance().getLocalSecret());
+
}
--
Gitblit v1.8.0