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/ui/MyPowerStationActivity.java | 89 +++++++++++++++++++++++++++++++++++++-------
1 files changed, 74 insertions(+), 15 deletions(-)
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 2b7bca6..7e204c2 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
@@ -6,6 +6,8 @@
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
+import android.os.Process;
+import android.text.TextUtils;
import android.view.View;
import com.google.gson.Gson;
@@ -20,14 +22,17 @@
import com.hdl.photovoltaic.other.HdlDeviceLogic;
import com.hdl.photovoltaic.other.HdlLogLogic;
import com.hdl.photovoltaic.other.HdlMqttLogic;
+import com.hdl.photovoltaic.other.HdlThreadLogic;
import com.hdl.photovoltaic.other.HdlUniLogic;
import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo;
import com.hdl.photovoltaic.uni.HDLUniMP;
+import com.hdl.photovoltaic.utils.AppManagerUtils;
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.EventNotifyRefreshGatewayAesKeyInfo;
+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;
@@ -48,6 +53,8 @@
private int currentFragmentIndex = 1;
private EventListener allTopicsListener;
+ private int backPressTimes;
+
@Override
public Object getContentView() {
@@ -57,7 +64,7 @@
@Override
public void onBindView(Bundle savedInstanceState) {
- getWindow().setStatusBarColor(getColor(R.color.text_245EC3));
+
//鍒濆鍖�
initView();
//鍒濆鍖栫晫闈㈢洃鍚櫒
@@ -115,9 +122,9 @@
private void bottomViewChangeOfStyle() {
if (this.currentFragmentIndex == 1) {
- viewBinding.myPowerStationFcv1.setVisibility(View.VISIBLE);
- viewBinding.myMessageFcv2.setVisibility(View.GONE);
- viewBinding.myMeFcv3.setVisibility(View.GONE);
+ viewBinding.myPowerStationFcv1.setVisibility(View.VISIBLE);//鏄剧ず鐢电珯鐣岄潰
+ viewBinding.myMessageFcv2.setVisibility(View.GONE);//闅愯棌娑堟伅鐣岄潰
+ viewBinding.myMeFcv3.setVisibility(View.GONE);//闅愯棌鎴戠殑鐣岄潰
viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.selectedpowerstation));
viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_90000000));
viewBinding.myMessageBottomIl2.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.message_unselected));
@@ -125,9 +132,9 @@
viewBinding.myMeBottomIl3.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.unselectedme));
viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_65000000));
} else if (this.currentFragmentIndex == 2) {
- viewBinding.myPowerStationFcv1.setVisibility(View.GONE);
- viewBinding.myMessageFcv2.setVisibility(View.VISIBLE);
- viewBinding.myMeFcv3.setVisibility(View.GONE);
+ viewBinding.myPowerStationFcv1.setVisibility(View.GONE);//闅愯棌鐢电珯鐣岄潰
+ viewBinding.myMessageFcv2.setVisibility(View.VISIBLE);//鏄剧ず娑堟伅鐣岄潰
+ viewBinding.myMeFcv3.setVisibility(View.GONE);//闅愯棌鎴戠殑鐣岄潰
viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.unselectedpowerstation));
viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_65000000));
viewBinding.myMessageBottomIl2.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.message_select));
@@ -135,9 +142,9 @@
viewBinding.myMeBottomIl3.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.unselectedme));
viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_65000000));
} else if (this.currentFragmentIndex == 3) {
- viewBinding.myPowerStationFcv1.setVisibility(View.GONE);
- viewBinding.myMessageFcv2.setVisibility(View.GONE);
- viewBinding.myMeFcv3.setVisibility(View.VISIBLE);
+ viewBinding.myPowerStationFcv1.setVisibility(View.GONE);//闅愯棌鐢电珯鐣岄潰
+ viewBinding.myMessageFcv2.setVisibility(View.GONE);//闅愯棌娑堟伅鐣岄潰
+ viewBinding.myMeFcv3.setVisibility(View.VISIBLE);//鏄剧ず鎴戠殑鐣岄潰
viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.unselectedpowerstation));
viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_65000000));
viewBinding.myMessageBottomIl2.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.message_unselected));
@@ -199,12 +206,15 @@
@Override
public void onMessage(Object msg) {
+ if (msg == null) {
+ return;
+ }
if (msg instanceof ModbusResponse) {
ModbusResponse response = (ModbusResponse) msg;
if (response.getTopic() == null) {
return;
}
- HdlLogLogic.print("鐩戝惉鍒扮殑鏁版嵁===========" + new Gson().toJson(response));
+ HdlLogLogic.print("鐩戝惉鍒扮殑鏁版嵁===" + new Gson().toJson(response), false);
// if (response.getTopic().endsWith("custom/native/inverter/up")) {
HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
uniCallBackBaseBean.setType(response.getTopic());
@@ -212,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);
+ }
}
}
};
@@ -232,22 +253,30 @@
@Override
public void onFailure(HDLException e) {
- HdlLogLogic.print("璇诲彇mqtt杩滅▼淇℃伅澶辫触", e.getMessage(), e.getCode());
+ HdlLogLogic.print("璇诲彇mqtt杩滅▼淇℃伅澶辫触===" + e.getMessage(), e.getCode(), true);
}
});
}
@Subscribe(threadMode = ThreadMode.MAIN)
- public void onEventMessage(EventNotifyRefreshGatewayAesKeyInfo event) {
+ public void onEventMessage(BaseEventBus event) {
//缃戝叧鏇存柊mqtt绉橀挜鏇存柊閫氱煡
if (event == null) {
+ return;
+ }
+ if (TextUtils.isEmpty(event.getTopic())) {
+ return;
+ }
+ String[] topics = event.getTopic().split("/");
+ //涓婚涓嶇鍚堣鍒欎笉澶勭悊
+ if (topics.length < 3) {
return;
}
int index = -1;
List<GatewayBean> list = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList();
for (int i = 0; i < list.size(); i++) {
GatewayBean gatewayBean = list.get(i);
- if (gatewayBean.getGatewayId().equals(event.getGatewayId())) {
+ if (gatewayBean.getGatewayId().equals(topics[2])) {
index = i;
break;
}
@@ -276,4 +305,34 @@
}
+ /**
+ * 鐐瑰嚮杩斿洖閿殑浜嬩欢
+ */
+ @Override
+ public void onBackPressed() {
+ if (AppManagerUtils.getAppManager().getActivitySize() <= 1) {
+ if (backPressTimes == 0) {
+ HdlThreadLogic.toast(_mActivity, R.string.kill_app);
+ backPressTimes = 1;
+ new Thread() {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } finally {
+ backPressTimes = 0;
+ }
+ }
+ }.start();
+ return;
+ } else {
+ AppManagerUtils.getAppManager().finishAllActivity();
+ Process.killProcess(Process.myPid());
+ }
+ }
+ super.onBackPressed();
+ }
+
}
\ No newline at end of file
--
Gitblit v1.8.0