From c96a5eb14685ca81771d3fa4e28ccc77db54a989 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期日, 25 六月 2023 18:29:56 +0800
Subject: [PATCH] 2023年06月25日18:29:53

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlThreadLogic.java |   51 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlThreadLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlThreadLogic.java
index 0922c13..13d7ea1 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlThreadLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlThreadLogic.java
@@ -9,6 +9,7 @@
 import androidx.appcompat.app.AlertDialog;
 
 import com.hdl.photovoltaic.enums.ShowErrorMode;
+import com.hdl.photovoltaic.widget.ConfirmationDialog;
 
 /**
  * 绾跨▼閫昏緫
@@ -86,12 +87,12 @@
 
 
     /**
-     * @param e             寮傚父淇℃伅绫�
+     * @param ex            寮傚父淇℃伅绫�
      * @param context       涓婁笅鏂�(涓嶉渶瑕佸脊妗嗗~null)
      * @param showErrorMode 鏄惁鏄剧ず閿欒(涓嶉渶瑕佸~null)
      */
-    private static void exception(Exception e, ShowErrorMode showErrorMode, Context context) {
-        if (showErrorMode == null || context == null || e == null) {
+    private static void exception(Exception ex, ShowErrorMode showErrorMode, Context context) {
+        if (showErrorMode == null || context == null || ex == null) {
             return;
         }
         if (showErrorMode == ShowErrorMode.NO) {
@@ -101,18 +102,42 @@
         handler.post(new Runnable() {
             @Override
             public void run() {
-                Dialog alertDialog = new AlertDialog.Builder(context).
-                        setTitle("鎶辨瓑绋嬪簭鍑虹幇閿欒浜�,鐐瑰嚮\"纭\"鑾峰彇鏇村璇︾粏淇℃伅.").
-                        setMessage(e.getMessage()).
-                        create();
-                alertDialog.show();
-                //鎻愮ず
-//                AlertDialog alertDialog = new AlertDialog(context, androidx.fragment.R.style.TextAppearance_Compat_Notification);
-//                alertDialog.setTitle("鎶辨瓑绋嬪簭鍑虹幇閿欒浜�");
-//                alertDialog.show();
-//                Toast.makeText(context, "鎶辨瓑绋嬪簭鍑虹幇閿欒浜�", Toast.LENGTH_SHORT).show();
+
+                ConfirmationDialog confirmationDialog = new ConfirmationDialog(context);
+                confirmationDialog.setTitle("鎻愮ず");
+                confirmationDialog.setContent("寰堟姳姝�,绋嬪簭鍑虹幇閿欒浜�,鐐瑰嚮\"纭\"鑾峰彇鏇村璇︾粏閿欒淇℃伅.");
+                confirmationDialog.setConfirmation("纭");
+                confirmationDialog.setCancel("鍙栨秷");
+                confirmationDialog.show();
+                confirmationDialog.setNoOnclickListener(new ConfirmationDialog.onNoOnclickListener() {
+                    @Override
+                    public void Cancel() {
+                        confirmationDialog.dismiss();
+                    }
+                });
+                confirmationDialog.setYesOnclickListener(new ConfirmationDialog.onYesOnclickListener() {
+                    @Override
+                    public void Confirm() {
+                        confirmationDialog.dismiss();
+                        String s = getStackTrace(ex);
+
+                    }
+                });
 
             }
         });
     }
+
+    /**
+     * @return 璋冪敤鏍�
+     */
+    private static String getStackTrace(Exception ex) {
+        StringBuilder sb = new StringBuilder("");
+        StackTraceElement[] trace = ex.getStackTrace();
+        for (StackTraceElement stackTraceElement : trace) {
+            sb.append(stackTraceElement).append("\n");
+        }
+        return sb.toString();
+    }
+
 }

--
Gitblit v1.8.0