From a399dc449dc962c088c2cacbc4c32d503ced816f Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期三, 04 十二月 2024 18:58:41 +0800 Subject: [PATCH] 2024年12月04日18:58:39 --- app/src/main/java/com/hdl/photovoltaic/other/HdlThreadLogic.java | 36 ++++++++++++++++++++++++++++-------- 1 files changed, 28 insertions(+), 8 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 cf9ef43..b311b03 100644 --- a/app/src/main/java/com/hdl/photovoltaic/other/HdlThreadLogic.java +++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlThreadLogic.java @@ -14,7 +14,7 @@ import com.hdl.photovoltaic.enums.ShowErrorMode; import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; import com.hdl.photovoltaic.widget.ConfirmationExceptionDialog; -import com.hdl.photovoltaic.widget.FlashingBoxDialog; +import com.hdl.photovoltaic.widget.FlashingIconBoxDialog; /** * 绾跨▼閫昏緫 @@ -141,26 +141,46 @@ /** - * 閿欒鎻愮ず妗嗭紙钃濇箹涓婃牱寮忥級 + * 鍏ㄥ眬寮瑰嚭妗�,閿欒鎻愮ず妗嗭紙钃濇箹涓婃牱寮忥級 * * @param isBoolean 鍥炬爣(true浣跨敤鎴愬姛鍥炬爣,false浣跨敤鎴愬姛鍥炬爣) * @param msg 淇℃伅 * @param code 鐘舵�� */ public static void tipFlashingBox(Context context, boolean isBoolean, String msg, int code) { + tipFlashingBox(context, isBoolean, msg, code, 1500); + } + + /** + * 鍏ㄥ眬寮瑰嚭妗�,閿欒鎻愮ず妗嗭紙钃濇箹涓婃牱寮忥級 + * + * @param isBoolean 鍥炬爣(true浣跨敤鎴愬姛鍥炬爣,false浣跨敤鎴愬姛鍥炬爣) + * @param msg 淇℃伅 + * @param code 鐘舵�� + * @param millisecond 璁剧疆寤舵椂鏃堕棿鍏抽棴寮圭獥(鍗曚綅ms) + */ + public static void tipFlashingBox(Context context, boolean isBoolean, String msg, int code, int millisecond) { + if (context == null) { + return; + } HdlThreadLogic.runMainThread(new Runnable() { @Override public void run() { - FlashingBoxDialog flashingBoxDialog = new FlashingBoxDialog(context); + FlashingIconBoxDialog flashingIconBoxDialog = new FlashingIconBoxDialog(context, millisecond); if (isBoolean) { Drawable drawable = AppCompatResources.getDrawable(context, R.drawable.tip_succeed); - flashingBoxDialog.setImage(drawable); + flashingIconBoxDialog.setImage(drawable); } else { Drawable drawable = AppCompatResources.getDrawable(context, R.drawable.tip_fail); - flashingBoxDialog.setImage(drawable); + flashingIconBoxDialog.setImage(drawable); } - flashingBoxDialog.setContent(msg + "\r\n(" + code + ")"); - flashingBoxDialog.show(); + if (code == 0) { + //鎴愬姛涓嶉渶瑕佸鍔犵姸鎬佺爜 + flashingIconBoxDialog.setContent(msg); + } else { + flashingIconBoxDialog.setContent(msg + "(" + code + ")"); + } + flashingIconBoxDialog.show(); } }, null, null); } @@ -214,7 +234,7 @@ * @return 璋冪敤鏍� */ private static String getStackTrace(Exception ex) { - StringBuilder sb = new StringBuilder(""); + StringBuilder sb = new StringBuilder(); StackTraceElement[] trace = ex.getStackTrace(); for (StackTraceElement stackTraceElement : trace) { sb.append(stackTraceElement).append("\n"); -- Gitblit v1.8.0