From 1863007fd5fc407af48a27c47362e0b1345b668a Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期一, 23 十二月 2024 20:51:33 +0800 Subject: [PATCH] (修改新主题)2024年12月23日20:51:09 --- app/src/main/java/com/hdl/photovoltaic/other/HdlThreadLogic.java | 42 +++++++++++++++++++++++++++++++++++------- 1 files changed, 35 insertions(+), 7 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..2acd26f 100644 --- a/app/src/main/java/com/hdl/photovoltaic/other/HdlThreadLogic.java +++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlThreadLogic.java @@ -15,6 +15,7 @@ import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; import com.hdl.photovoltaic.widget.ConfirmationExceptionDialog; import com.hdl.photovoltaic.widget.FlashingBoxDialog; +import com.hdl.photovoltaic.widget.FlashingIconBoxDialog; /** * 绾跨▼閫昏緫 @@ -110,6 +111,9 @@ handler.post(new Runnable() { @Override public void run() { +// FlashingBoxDialog flashingIconBoxDialog = new FlashingBoxDialog(context, 1500); +// flashingIconBoxDialog.setContent(text); +// flashingIconBoxDialog.show(); Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); } }); @@ -122,6 +126,9 @@ handler.post(new Runnable() { @Override public void run() { +// FlashingBoxDialog flashingIconBoxDialog = new FlashingBoxDialog(context, 1500); +// flashingIconBoxDialog.setContent(hdlException.getMsg() + "(" + hdlException.getCode() + ")"); +// flashingIconBoxDialog.show(); Toast.makeText(context, hdlException.getMsg() + "(" + hdlException.getCode() + ")", Toast.LENGTH_SHORT).show(); } }); @@ -134,6 +141,7 @@ handler.post(new Runnable() { @Override public void run() { + Toast.makeText(context, resId, Toast.LENGTH_SHORT).show(); } }); @@ -141,26 +149,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 +242,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