From 9e875b253959eff8f6af567308ad804fe69d0a62 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期五, 03 十一月 2023 18:04:57 +0800
Subject: [PATCH] 2023年11月03日18:04:44
---
app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java | 39 +++++++++++++++++++++++++++++++++++++--
1 files changed, 37 insertions(+), 2 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 03ca70c..d80232f 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,7 @@
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
+import android.os.Process;
import android.view.View;
import com.google.gson.Gson;
@@ -20,9 +21,11 @@
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;
@@ -47,6 +50,8 @@
private ActivityMyPowerStationBinding viewBinding;
private int currentFragmentIndex = 1;
private EventListener allTopicsListener;
+
+ private int backPressTimes;
@Override
@@ -204,7 +209,7 @@
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());
@@ -232,7 +237,7 @@
@Override
public void onFailure(HDLException e) {
- HdlLogLogic.print("璇诲彇mqtt杩滅▼淇℃伅澶辫触", e.getMessage(), e.getCode());
+ HdlLogLogic.print("璇诲彇mqtt杩滅▼淇℃伅澶辫触==="+e.getMessage(), e.getCode(),true);
}
});
}
@@ -276,4 +281,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