Ver Fonte

优化弹窗提示

lhm há 3 anos atrás
pai
commit
7979dce56a
1 ficheiros alterados com 11 adições e 8 exclusões
  1. 11 8
      app/src/main/java/com/emato/ich/utils/ToastUtils.java

+ 11 - 8
app/src/main/java/com/emato/ich/utils/ToastUtils.java

@@ -17,13 +17,13 @@ public class ToastUtils {
 
     private static Toast mToast;
     private static Handler mHandler = new Handler();
-    private static Runnable runnable = new Runnable() {
-        public void run() {
-            mToast.cancel();
-            //toast隐藏后,将其置为null
-            mToast=null;
-        }
-    };
+//    private static Runnable runnable = new Runnable() {
+//        public void run() {
+//            mToast.cancel();
+//            //toast隐藏后,将其置为null
+//            mToast=null;
+//        }
+//    };
 
     /**
      * 弹出框
@@ -38,13 +38,16 @@ public class ToastUtils {
         //显示的提示文字
         text.setText(msg);
 //        mHandler.removeCallbacks(runnable);
+        if (mToast != null) {
+            mToast.cancel();
+        }
         mToast = new Toast(context);
         mToast.setDuration(Toast.LENGTH_SHORT);
         mToast.setGravity(Gravity.CENTER, 0, -22);
         mToast.setView(view);
         mToast.show();
 
-        mHandler.removeCallbacks(runnable);
+//        mHandler.removeCallbacks(runnable);
     }
 
 }