From f10bd384ab2c5e459b9bf20766970615e429b4ec Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 16 十一月 2023 16:53:22 +0800
Subject: [PATCH] 备份一下代码
---
app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java | 4 --
app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java | 12 +++++
app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java | 16 +++++++
app/src/main/java/com/hdl/photovoltaic/utils/HDLMD5Utils.java | 2 +
app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java | 41 +++++++++++++-------
5 files changed, 54 insertions(+), 21 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java b/app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java
index f74016b..6a2b68c 100644
--- a/app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java
@@ -1,6 +1,7 @@
package com.hdl.photovoltaic.base;
import android.app.Activity;
+import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
@@ -26,10 +27,11 @@
private LoadingDialog loadingDialog;
protected Activity _mActivity;
+
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- LocalManageUtil.changeAppLanguage("en", this);
+
_mActivity = this;
Object content = getContentView();
//娣诲姞Activity鍒板爢鏍�
@@ -47,6 +49,14 @@
}
+ @Override
+ protected void attachBaseContext(Context newBase) {
+ super.attachBaseContext(newBase);
+// //app涓嫳鏂囪缃�
+// LocalManageUtil.changeAppLanguage("en", newBase);
+
+ }
+
/**
* 鑾峰彇LoadingDialog
*
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 88f735e..27b5ee8 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -90,7 +90,8 @@
if (TextUtils.isEmpty(gatewayBean.getDevice_mac())) {
continue;
}
- if (gatewayBean.getMaster().equals(GatewayMasterType.MasterTrue) && gatewayBean.getHomeId().equals(UserConfigManage.getInstance().getHomeId())) {
+ //鐢╤omeId绛涢�夊綋鍓嶄綇瀹呯殑閫嗗彉鍣ㄥ垪琛�
+ if (gatewayBean.getHomeId().equals(UserConfigManage.getInstance().getHomeId())) {
newList.add(gatewayBean);
}
}
@@ -117,7 +118,6 @@
}
return null;
}
-
/**
@@ -564,7 +564,7 @@
/**
* 鑾峰彇閫嗗彉鍣ㄥ垪琛�
- * 娉ㄦ剰:鏈夊缃戜互浜戠璁惧涓哄噯;鏈湴瀛樺湪锛屼簯绔病鏈夊垯鍒犻櫎锛涘唴缃戜互鏈湴涓轰富,鎼滅储澶氬皯涓澶囧氨鏄剧ず澶氬皯涓紱
+ * 娉ㄦ剰:鏈夊缃戜互浜戠璁惧涓哄噯,鏈湴瀛樺湪锛屼簯绔病鏈夊垯鍒犻櫎锛涘唴缃戜互鏈湴涓轰富,鎼滅储澶氬皯涓澶囧氨鏄剧ず澶氬皯涓紱
*
* @param cloudCallBeak 杩斿洖閫嗗彉鍣ㄥ垪琛�
*/
@@ -572,13 +572,13 @@
HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() {
@Override
public void onSuccess(List<GatewayBean> gatewayBeanList) {
- //灞�鍩熺綉鎯呭喌
+ //灞�鍩熺綉鏈�2绉嶆儏鍐�(1:鏈夊眬鍩熺綉锛屾湁澶栫綉锛�2:鏈夊眬鍩熺綉锛屾病鏈夊缃�);
HdlDeviceLogic.getInstance().getCloudInverterDeviceList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<List<CloudInverterDeviceBean>>() {
@Override
public void onSuccess(List<CloudInverterDeviceBean> list) {
+ ///鎯呭喌1:鏈夊眬鍩熺綉锛屾湁澶栫綉锛�
if (list == null || list.size() == 0) {
-// //浜戠娌℃湁缁戝畾閫嗗彉鍣�,浠ユ湰鍦颁负涓�;
-// HDLLinkLocalGateway.getInstance().getGatewayList().clear();
+ //浜戠娌℃湁缁戝畾閫嗗彉鍣�,榛樿杩斿洖鏈湴閫嗗彉鍣ㄥ垪琛�;
if (cloudCallBeak != null) {
cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
}
@@ -588,11 +588,14 @@
AtomicInteger atomicInteger = new AtomicInteger(0);
for (int i = 0; i < list.size(); i++) {
CloudInverterDeviceBean cloudInverterDeviceBean = list.get(i);
+ //鑾峰彇杩滅▼璁惧閫氳淇℃伅(鎷垮埌缃戝叧ID锛宮qtt閫氳绉橀挜)
getDeviceRemoteInfo(UserConfigManage.getInstance().getHomeId(), cloudInverterDeviceBean.getSpk(), cloudInverterDeviceBean.getOsn(), new CloudCallBeak<DeviceRemoteInfo>() {
@Override
public void onSuccess(DeviceRemoteInfo deviceRemoteInfo) {
atomicInteger.set(atomicInteger.get() + 1);
+ //鏇存柊閫嗗彉鍣ㄦ湰鍦扮紦瀛樹俊鎭�
refreshGatewayCacheData(true, cloudInverterDeviceBean, deviceRemoteInfo);
+ //鏈�鍚庝竴鏉℃墠鍋氬垹闄ら�嗗彉鍣ㄩ�昏緫澶勭悊
if (atomicInteger.get() == list.size()) {
//鏀堕泦鍒犻櫎閫嗗彉鍣╯id
List<String> removeSidList = new ArrayList<>();
@@ -620,7 +623,7 @@
@Override
public void onFailure(HDLException e) {
atomicInteger.set(atomicInteger.get() + 1);
- //鏈夊彲鑳芥渶鍚庝竴鏉℃槸澶辫触鐨�
+ //褰撴渶鍚庝竴鏉¤姹傚け璐ヤ簡锛屾墠鍦ㄨ繖閲屽仛鍒犻櫎閫嗗彉鍣ㄩ�昏緫澶勭悊
if (atomicInteger.get() == list.size()) {
//鏀堕泦鍒犻櫎閫嗗彉鍣╯id
List<String> removeSidList = new ArrayList<>();
@@ -653,8 +656,10 @@
@Override
public void onFailure(HDLException e) {
+ ///鎯呭喌2:鏈夊眬鍩熺綉锛屾病鏈夊缃�;
+ //鏈湴鏈夐�嗗彉鍣ㄥ垪琛�,鑾峰彇浜戠缁戝畾閫嗗彉鍣ㄥけ璐�,榛樿杩斿洖鏈湴閫嗗彉鍣ㄥ垪琛�;
if (cloudCallBeak != null) {
- cloudCallBeak.onFailure(e);
+ cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
}
}
});
@@ -662,27 +667,32 @@
@Override
public void onError(HDLLinkException e) {
- //澶栫綉鎯呭喌
+ //澶栫綉鍙湁1鎯呭喌(鏈湴鎼滅储閫嗗彉鍣ㄥ垪琛ㄥけ璐ヤ簡)
HdlDeviceLogic.getInstance().getCloudInverterDeviceList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<List<CloudInverterDeviceBean>>() {
@Override
public void onSuccess(List<CloudInverterDeviceBean> list) {
- //浜戠娌℃湁,娓呯┖鏈湴閫嗗彉鍣ㄥ垪琛�
+ //澶栫綉杩涙潵鍏堛�愰粯璁ゃ�戞竻绌烘湰鍦伴�嗗彉鍣ㄥ垪琛�
HDLLinkLocalGateway.getInstance().getGatewayList().clear();
if (list == null || list.size() == 0) {
if (cloudCallBeak != null) {
- cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
+ //浜戠涔熸病鏈夐�嗗彉鍣ㄥ垪琛�,杩斿洖绌哄垪琛ㄥ洖鍘�
+ cloudCallBeak.onSuccess(new ArrayList<>());
}
return;
}
//璁板綍鏉℃暟
AtomicInteger atomicInteger = new AtomicInteger(0);
+
for (int i = 0; i < list.size(); i++) {
CloudInverterDeviceBean cloudInverterDeviceBean = list.get(i);
+ //鑾峰彇杩滅▼璁惧閫氳淇℃伅(鎷垮埌缃戝叧ID锛宮qtt閫氳绉橀挜)
getDeviceRemoteInfo(UserConfigManage.getInstance().getHomeId(), cloudInverterDeviceBean.getSpk(), cloudInverterDeviceBean.getOsn(), new CloudCallBeak<DeviceRemoteInfo>() {
@Override
public void onSuccess(DeviceRemoteInfo deviceRemoteInfo) {
atomicInteger.set(atomicInteger.get() + 1);
+ //鏇存柊閫嗗彉鍣ㄦ湰鍦扮紦瀛樹俊鎭�
refreshGatewayCacheData(false, cloudInverterDeviceBean, deviceRemoteInfo);
+ //鍒版渶鍚庝竴鏉★紝鎵嶆湁鍥炶皟
if (atomicInteger.get() == list.size()) {
if (cloudCallBeak != null) {
cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
@@ -693,6 +703,7 @@
@Override
public void onFailure(HDLException e) {
atomicInteger.set(atomicInteger.get() + 1);
+ //褰撴渶鍚庝竴鏉¤姹傚け璐ヤ簡锛屾墠鏈夊洖璋�
if (atomicInteger.get() == list.size()) {
if (cloudCallBeak != null) {
cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
@@ -817,8 +828,8 @@
/**
* 鍒锋柊閫嗗彉鍣ㄧ紦瀛樹俊鎭�(鍖呮嫭璁剧疆mqtt绉橀挜锛�
* 娉�:
- * 1:鏈湴瀛樺湪鏇存柊淇℃伅鍗冲彲;
- * 2:浜戠鏈夋湰鍦颁笉瀛樺湪,鍒欒櫄鎷熶竴涓�嗗彉鍣ㄥ璞℃坊鍔犲湪鏈湴;
+ * 1:鏈湴瀛樺湪,鏇存柊淇℃伅鍗冲彲;
+ * 2:鏈湴涓嶅瓨鍦�,鍒欒櫄鎷熶竴涓�嗗彉鍣ㄥ璞℃坊鍔犲湪鏈湴;
*
* @param deviceRemoteInfo 璁惧杩滅▼閫氳淇℃伅
* @param cloudInverterDeviceBean 閫嗗彉鍣�
@@ -849,7 +860,7 @@
gatewayBean.setDevice_name(cloudInverterDeviceBean.getName());//璁惧鍚嶇О
gatewayBean.setGatewayType(cloudInverterDeviceBean.getSpk());//璁剧疆spk
gatewayBean.setLocalEncrypt(true);
- gatewayBean.setMaster(GatewayMasterType.MasterTrue);
+ gatewayBean.setMaster(GatewayMasterType.MasterTrue);//榛樿閮芥槸涓婚�嗗彉鍣�(浠ュ悗鏀寔浠庨�嗗彉鍣ㄨ鏇存敼)
gatewayBean.setSystemStatusDesc(cloudInverterDeviceBean.getSystemStatusDesc());//璁惧鐘舵��
gatewayBean.setHwVersion(cloudInverterDeviceBean.getHwVersion());//杞欢鐗堟湰鍙�
gatewayBean.setCategorySecondName(cloudInverterDeviceBean.getCategorySecondName());//璁惧绫诲瀷(浜у搧浜岀骇鍒嗙被鍚嶇О
@@ -864,7 +875,7 @@
/**
- * 鑾峰彇缃戝叧spk鍒楄〃
+ * 鑾峰彇缃戝叧鏀寔spk鍒楄〃
*
* @return -
*/
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
index 4885c41..7e204c2 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
@@ -30,9 +30,9 @@
import com.hdl.photovoltaic.utils.PermissionUtils;
import com.hdl.sdk.link.HDLLinkLocalSdk;
import com.hdl.sdk.link.common.event.EventListener;
+import com.hdl.sdk.link.core.bean.LinkResponse;
import com.hdl.sdk.link.core.bean.ModbusResponse;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
-import com.hdl.sdk.link.core.bean.eventbus.EventNotifyRefreshGatewayAesKeyInfo;
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;
@@ -206,6 +206,9 @@
@Override
public void onMessage(Object msg) {
+ if (msg == null) {
+ return;
+ }
if (msg instanceof ModbusResponse) {
ModbusResponse response = (ModbusResponse) msg;
if (response.getTopic() == null) {
@@ -219,6 +222,17 @@
HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean);
// }
+ } else if (msg instanceof LinkResponse) {
+ LinkResponse linkResponse = (LinkResponse) msg;
+ if (linkResponse.getTopic() == null) {
+ return;
+ }
+ if (linkResponse.getTopic().endsWith("/ota/device/progress/up")) {
+ HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
+ uniCallBackBaseBean.setType(linkResponse.getTopic());
+ uniCallBackBaseBean.setData(linkResponse.getData());
+ HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_REPLY_OTA_MODEL, uniCallBackBaseBean);
+ }
}
}
};
diff --git a/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java b/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
index c6adc55..1157256 100644
--- a/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
+++ b/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
@@ -1,10 +1,6 @@
package com.hdl.photovoltaic.uni;
-import com.google.gson.Gson;
-
-import org.json.JSONObject;
-
import java.io.Serializable;
/**
diff --git a/app/src/main/java/com/hdl/photovoltaic/utils/HDLMD5Utils.java b/app/src/main/java/com/hdl/photovoltaic/utils/HDLMD5Utils.java
index 84ffec6..c51dfcf 100644
--- a/app/src/main/java/com/hdl/photovoltaic/utils/HDLMD5Utils.java
+++ b/app/src/main/java/com/hdl/photovoltaic/utils/HDLMD5Utils.java
@@ -107,6 +107,8 @@
}
+
+
public final static String md5(String plainText) {
// 杩斿洖瀛楃涓�
--
Gitblit v1.8.0