Browse Source

0.0.36 update

kongzue 4 years ago
parent
commit
fe950b932b

+ 3 - 0
DialogX/src/main/java/com/kongzue/dialogx/DialogX.java

@@ -100,6 +100,9 @@ public class DialogX {
     //全局 Dialog 生命周期监听器
     public static DialogLifecycleCallback<BaseDialog> dialogLifeCycleListener;
     
+    //是否自动在主线程执行
+    public static boolean autoRunOnUIThread = true;
+    
     public enum THEME {
         LIGHT, DARK, AUTO
     }

+ 4 - 14
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomDialog.java

@@ -285,8 +285,6 @@ public class BottomDialog extends BaseDialog {
                     
                     onDialogInit(dialogImpl);
                     
-                    if (onBindView != null) onBindView.onBind(me, onBindView.getCustomView());
-                    
                     if (style.messageDialogBlurSettings() != null && style.messageDialogBlurSettings().blurBackground() && boxBody != null && boxCancel != null) {
                         int blurFrontColor = getResources().getColor(style.messageDialogBlurSettings().blurForwardColorRes(isLightTheme()));
                         blurView = new BlurView(bkg.getContext(), null);
@@ -459,15 +457,8 @@ public class BottomDialog extends BaseDialog {
             
             if (maskColor != -1) boxRoot.setBackgroundColor(maskColor);
             
-            if (onBindView != null) {
-                if (onBindView.getCustomView() != null) {
-                    boxCustom.removeView(onBindView.getCustomView());
-                    ViewGroup.LayoutParams lp = boxCustom.getLayoutParams();
-                    if (lp == null) {
-                        lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
-                    }
-                    boxCustom.addView(onBindView.getCustomView(), lp);
-                }
+            if (onBindView != null && onBindView.getCustomView() != null) {
+                onBindView.bindParent(boxCustom, me);
             }
             
             if (isAllowInterceptTouch() && isCancelable()) {
@@ -537,8 +528,7 @@ public class BottomDialog extends BaseDialog {
     }
     
     public void refreshUI() {
-        if (getRootFrameLayout() == null) return;
-        getRootFrameLayout().post(new Runnable() {
+        runOnMain(new Runnable() {
             @Override
             public void run() {
                 if (dialogImpl != null) dialogImpl.refreshView();
@@ -858,7 +848,7 @@ public class BottomDialog extends BaseDialog {
         if (style.overrideBottomDialogRes() != null) {
             layoutId = style.overrideBottomDialogRes().overrideDialogLayout(isLightTheme());
         }
-    
+        
         enterAnimDuration = 0;
         dialogView = createView(layoutId);
         dialogImpl = new DialogImpl(dialogView);

+ 17 - 13
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomMenu.java

@@ -529,21 +529,25 @@ public class BottomMenu extends BottomDialog {
     @Override
     public void refreshUI() {
         super.refreshUI();
-        
-        if (listView != null) {
-            if (menuListAdapter == null) {
-                menuListAdapter = new NormalMenuArrayAdapter(me, getContext(), menuList);
-            }
-            if (listView.getAdapter() == null) {
-                listView.setAdapter(menuListAdapter);
-            } else {
-                if (listView.getAdapter() != menuListAdapter) {
-                    listView.setAdapter(menuListAdapter);
-                } else {
-                    menuListAdapter.notifyDataSetChanged();
+        runOnMain(new Runnable() {
+            @Override
+            public void run() {
+                if (listView != null) {
+                    if (menuListAdapter == null) {
+                        menuListAdapter = new NormalMenuArrayAdapter(me, getContext(), menuList);
+                    }
+                    if (listView.getAdapter() == null) {
+                        listView.setAdapter(menuListAdapter);
+                    } else {
+                        if (listView.getAdapter() != menuListAdapter) {
+                            listView.setAdapter(menuListAdapter);
+                        } else {
+                            menuListAdapter.notifyDataSetChanged();
+                        }
+                    }
                 }
             }
-        }
+        });
     }
     
     @Override

+ 3 - 12
DialogX/src/main/java/com/kongzue/dialogx/dialogs/CustomDialog.java

@@ -115,7 +115,6 @@ public class CustomDialog extends BaseDialog {
                     isShow = true;
                     getDialogLifecycleCallback().onShow(me);
                     boxCustom.setVisibility(View.GONE);
-                    if (onBindView != null) onBindView.onBind(me, onBindView.getCustomView());
                 }
                 
                 @Override
@@ -223,15 +222,8 @@ public class CustomDialog extends BaseDialog {
             
             boxRoot.setBackgroundColor(maskColor);
             
-            if (onBindView != null) {
-                if (onBindView.getCustomView() != null) {
-                    boxCustom.removeView(onBindView.getCustomView());
-                    ViewGroup.LayoutParams lp = onBindView.getCustomView().getLayoutParams();
-                    if (lp == null) {
-                        lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
-                    }
-                    boxCustom.addView(onBindView.getCustomView(), lp);
-                }
+            if (onBindView != null && onBindView.getCustomView() != null) {
+                onBindView.bindParent(boxCustom, me);
             }
         }
         
@@ -269,8 +261,7 @@ public class CustomDialog extends BaseDialog {
     }
     
     public void refreshUI() {
-        if (getRootFrameLayout() == null) return;
-        getRootFrameLayout().post(new Runnable() {
+        runOnMain(new Runnable() {
             @Override
             public void run() {
                 if (dialogImpl != null) dialogImpl.refreshView();

+ 5 - 15
DialogX/src/main/java/com/kongzue/dialogx/dialogs/FullScreenDialog.java

@@ -84,7 +84,7 @@ public class FullScreenDialog extends BaseDialog {
     
     protected DialogImpl dialogImpl;
     
-    public class DialogImpl implements DialogConvertViewInterface  {
+    public class DialogImpl implements DialogConvertViewInterface {
         
         private FullScreenDialogTouchEventInterceptor fullScreenDialogTouchEventInterceptor;
         
@@ -116,8 +116,6 @@ public class FullScreenDialog extends BaseDialog {
                     boxRoot.setAlpha(0f);
                     
                     getDialogLifecycleCallback().onShow(me);
-                    
-                    if (onBindView != null) onBindView.onBind(me, onBindView.getCustomView());
                 }
                 
                 @Override
@@ -202,15 +200,8 @@ public class FullScreenDialog extends BaseDialog {
                 boxRoot.setOnClickListener(null);
             }
             
-            if (onBindView != null) {
-                if (onBindView.getCustomView() != null) {
-                    boxCustom.removeView(onBindView.getCustomView());
-                    ViewGroup.LayoutParams lp = onBindView.getCustomView().getLayoutParams();
-                    if (lp == null) {
-                        lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
-                    }
-                    boxCustom.addView(onBindView.getCustomView(), lp);
-                }
+            if (onBindView != null && onBindView.getCustomView() != null){
+                onBindView.bindParent(boxCustom, me);
             }
             
             fullScreenDialogTouchEventInterceptor.refresh(me, this);
@@ -253,8 +244,7 @@ public class FullScreenDialog extends BaseDialog {
     }
     
     public void refreshUI() {
-        if (getRootFrameLayout() == null) return;
-        getRootFrameLayout().post(new Runnable() {
+        runOnMain(new Runnable() {
             @Override
             public void run() {
                 if (dialogImpl != null) dialogImpl.refreshView();
@@ -373,7 +363,7 @@ public class FullScreenDialog extends BaseDialog {
         if (dialogView != null) {
             dismiss(dialogView);
         }
-        if (getDialogImpl().boxCustom!=null){
+        if (getDialogImpl().boxCustom != null) {
             getDialogImpl().boxCustom.removeAllViews();
         }
         enterAnimDuration = 0;

+ 2 - 10
DialogX/src/main/java/com/kongzue/dialogx/dialogs/MessageDialog.java

@@ -214,8 +214,7 @@ public class MessageDialog extends BaseDialog {
     }
     
     public void refreshUI() {
-        if (getRootFrameLayout() == null) return;
-        getRootFrameLayout().post(new Runnable() {
+        runOnMain(new Runnable() {
             @Override
             public void run() {
                 if (dialogImpl != null) dialogImpl.refreshView();
@@ -331,8 +330,6 @@ public class MessageDialog extends BaseDialog {
                             txtInput.selectAll();
                         }
                     }
-                    
-                    if (onBindView != null) onBindView.onBind(me, onBindView.getCustomView());
                 }
                 
                 @Override
@@ -614,13 +611,8 @@ public class MessageDialog extends BaseDialog {
             }
             
             if (onBindView != null && onBindView.getCustomView() != null) {
-                boxCustom.removeView(onBindView.getCustomView());
-                ViewGroup.LayoutParams lp = boxCustom.getLayoutParams();
-                if (lp == null) {
-                    lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
-                }
+                onBindView.bindParent(boxCustom, me);
                 boxCustom.setVisibility(View.VISIBLE);
-                boxCustom.addView(onBindView.getCustomView(), lp);
             } else {
                 boxCustom.setVisibility(View.GONE);
             }

+ 9 - 18
DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopTip.java

@@ -397,8 +397,6 @@ public class PopTip extends BaseDialog {
                     boxRoot.setAlpha(0f);
                     
                     getDialogLifecycleCallback().onShow(me);
-                    
-                    if (onBindView != null) onBindView.onBind(me, onBindView.getCustomView());
                 }
                 
                 @Override
@@ -487,20 +485,14 @@ public class PopTip extends BaseDialog {
                 tintColor(boxBody, backgroundColor);
             }
             
-            if (onBindView != null) {
-                if (onBindView.getCustomView() != null) {
-                    boxCustom.removeView(onBindView.getCustomView());
-                    ViewGroup.LayoutParams lp = onBindView.getCustomView().getLayoutParams();
-                    if (lp == null) {
-                        lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
-                    }
-                    boxCustom.addView(onBindView.getCustomView(), lp);
-                    boxCustom.setVisibility(View.VISIBLE);
-                } else {
-                    boxCustom.setVisibility(View.GONE);
-                }
+            if (onBindView != null && onBindView.getCustomView() != null) {
+                onBindView.bindParent(boxCustom, me);
+                boxCustom.setVisibility(View.VISIBLE);
+            } else {
+                boxCustom.setVisibility(View.GONE);
             }
             
+            
             showText(txtDialogxPopText, message);
             showText(txtDialogxButton, buttonText);
             
@@ -563,7 +555,7 @@ public class PopTip extends BaseDialog {
     }
     
     private void moveUp() {
-        if (getDialogImpl()!=null && getDialogImpl().boxBody!=null){
+        if (getDialogImpl() != null && getDialogImpl().boxBody != null) {
             getDialogImpl().boxBody.post(new Runnable() {
                 @Override
                 public void run() {
@@ -579,7 +571,7 @@ public class PopTip extends BaseDialog {
                             break;
                         case TOP_INSIDE:
                             getDialogImpl().boxBody.animate()
-                                    .y(getDialogImpl().boxBody.getY() + getDialogImpl().boxBody.getHeight() -getDialogImpl().boxBody.getPaddingTop())
+                                    .y(getDialogImpl().boxBody.getY() + getDialogImpl().boxBody.getHeight() - getDialogImpl().boxBody.getPaddingTop())
                                     .setDuration(enterAnimDuration == -1 ? 300 : enterAnimDuration)
                                     .setInterpolator(new DecelerateInterpolator(2f))
                             ;
@@ -600,8 +592,7 @@ public class PopTip extends BaseDialog {
     }
     
     public void refreshUI() {
-        if (getRootFrameLayout() == null) return;
-        getRootFrameLayout().post(new Runnable() {
+        runOnMain(new Runnable() {
             @Override
             public void run() {
                 if (dialogImpl != null) dialogImpl.refreshView();

+ 35 - 28
DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java

@@ -243,27 +243,37 @@ public class WaitDialog extends BaseDialog {
     
     public WaitDialog show() {
         super.beforeShow();
-        int layoutResId = R.layout.layout_dialogx_wait;
-        if (style.overrideWaitTipRes() != null && style.overrideWaitTipRes().overrideWaitLayout(isLightTheme()) != 0) {
-            layoutResId = style.overrideWaitTipRes().overrideWaitLayout(isLightTheme());
-        }
-        dialogView = createView(layoutResId);
-        dialogImpl = new DialogImpl(dialogView);
-        dialogView.setTag(dialogKey());
-        show(dialogView);
+        runOnMain(new Runnable() {
+            @Override
+            public void run() {
+                int layoutResId = R.layout.layout_dialogx_wait;
+                if (style.overrideWaitTipRes() != null && style.overrideWaitTipRes().overrideWaitLayout(isLightTheme()) != 0) {
+                    layoutResId = style.overrideWaitTipRes().overrideWaitLayout(isLightTheme());
+                }
+                dialogView = createView(layoutResId);
+                dialogImpl = new DialogImpl(dialogView);
+                dialogView.setTag(dialogKey());
+                show(dialogView);
+            }
+        });
         return this;
     }
     
-    public WaitDialog show(Activity activity) {
+    public WaitDialog show(final Activity activity) {
         super.beforeShow();
-        int layoutResId = R.layout.layout_dialogx_wait;
-        if (style.overrideWaitTipRes() != null && style.overrideWaitTipRes().overrideWaitLayout(isLightTheme()) != 0) {
-            layoutResId = style.overrideWaitTipRes().overrideWaitLayout(isLightTheme());
-        }
-        dialogView = createView(layoutResId);
-        dialogImpl = new DialogImpl(dialogView);
-        dialogView.setTag(dialogKey());
-        show(activity, dialogView);
+        runOnMain(new Runnable() {
+            @Override
+            public void run() {
+                int layoutResId = R.layout.layout_dialogx_wait;
+                if (style.overrideWaitTipRes() != null && style.overrideWaitTipRes().overrideWaitLayout(isLightTheme()) != 0) {
+                    layoutResId = style.overrideWaitTipRes().overrideWaitLayout(isLightTheme());
+                }
+                dialogView = createView(layoutResId);
+                dialogImpl = new DialogImpl(dialogView);
+                dialogView.setTag(dialogKey());
+                show(activity, dialogView);
+            }
+        });
         return this;
     }
     
@@ -332,8 +342,6 @@ public class WaitDialog extends BaseDialog {
                             getDialogLifecycleCallback().onShow(me());
                         }
                     });
-                    
-                    if (onBindView != null) onBindView.onBind(me.get(), onBindView.getCustomView());
                 }
                 
                 @Override
@@ -410,14 +418,9 @@ public class WaitDialog extends BaseDialog {
             if (maskColor != -1) boxRoot.setBackgroundColor(maskColor);
             
             if (onBindView != null && onBindView.getCustomView() != null) {
-                boxCustomView.removeView(onBindView.getCustomView());
-                ViewGroup.LayoutParams lp = boxCustomView.getLayoutParams();
-                if (lp == null) {
-                    lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
-                }
+                onBindView.bindParent(boxCustomView, me.get());
                 boxCustomView.setVisibility(View.VISIBLE);
                 boxProgress.setVisibility(View.GONE);
-                boxCustomView.addView(onBindView.getCustomView(), lp);
             } else {
                 boxCustomView.setVisibility(View.GONE);
                 boxProgress.setVisibility(View.VISIBLE);
@@ -453,7 +456,7 @@ public class WaitDialog extends BaseDialog {
         }
         
         public void showTip(final TYPE tip) {
-            getMainHandler().post(new Runnable() {
+            runOnMain(new Runnable() {
                 @Override
                 public void run() {
                     showType = tip.ordinal();
@@ -509,8 +512,7 @@ public class WaitDialog extends BaseDialog {
     }
     
     public void refreshUI() {
-        if (getRootFrameLayout() == null) return;
-        getRootFrameLayout().post(new Runnable() {
+        runOnMain(new Runnable() {
             @Override
             public void run() {
                 if (dialogImpl != null) dialogImpl.refreshView();
@@ -588,6 +590,11 @@ public class WaitDialog extends BaseDialog {
         return cancelable;
     }
     
+    public WaitDialog setCancelable(boolean cancelable) {
+        privateCancelable = cancelable ? BOOLEAN.TRUE : BOOLEAN.FALSE;
+        return this;
+    }
+    
     /**
      * 用于从 WaitDialog 到 TipDialog 的消息设置
      * 此方法不会立即执行,而是等到动画衔接完成后由事件设置

+ 21 - 7
DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java

@@ -68,8 +68,8 @@ public abstract class BaseDialog {
     protected static void show(final View view) {
         if (rootFrameLayout == null || view == null || rootFrameLayout.get() == null) return;
         log(view.getTag() + ".show");
-    
-        getMainHandler().post(new Runnable() {
+        
+        runOnMain(new Runnable() {
             @Override
             public void run() {
                 rootFrameLayout.get().addView(view);
@@ -79,10 +79,16 @@ public abstract class BaseDialog {
     
     protected static void show(Activity activity, final View view) {
         if (activity == null || view == null) return;
+        if (activity.isDestroyed()) {
+            error(view.getTag() + ".show ERROR: activity is Destroyed.");
+            return;
+        }
         log(view.getTag() + ".show");
         final FrameLayout activityRootView = (FrameLayout) activity.getWindow().getDecorView();
-        if (activityRootView == null) return;
-        getMainHandler().post(new Runnable() {
+        if (activityRootView == null) {
+            return;
+        }
+        runOnMain(new Runnable() {
             @Override
             public void run() {
                 activityRootView.addView(view);
@@ -93,7 +99,7 @@ public abstract class BaseDialog {
     protected static void dismiss(final View dialogView) {
         log(dialogView.getTag() + ".dismiss");
         if (rootFrameLayout == null || dialogView == null) return;
-        getMainHandler().post(new Runnable() {
+        runOnMain(new Runnable() {
             @Override
             public void run() {
                 if (dialogView.getParent() == null || !(dialogView.getParent() instanceof ViewGroup)) {
@@ -265,7 +271,15 @@ public abstract class BaseDialog {
     
     public abstract String dialogKey();
     
-    protected static Handler getMainHandler(){
-        return new Handler(Looper.getMainLooper());
+    protected static void runOnMain(Runnable runnable) {
+        if (!DialogX.autoRunOnUIThread){
+            runnable.run();
+            return;
+        }
+        if (Looper.myLooper() == Looper.getMainLooper()) {
+            runnable.run();
+        } else {
+            new Handler(Looper.getMainLooper()).post(runnable);
+        }
     }
 }

+ 36 - 2
DialogX/src/main/java/com/kongzue/dialogx/interfaces/OnBindView.java

@@ -2,6 +2,7 @@ package com.kongzue.dialogx.interfaces;
 
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.ViewGroup;
 import android.widget.RelativeLayout;
 
 import com.kongzue.dialogx.DialogX;
@@ -20,12 +21,12 @@ public abstract class OnBindView<D> {
     View customView;
     
     public OnBindView(int layoutResId) {
-        if (BaseDialog.getContext() == null){
+        if (BaseDialog.getContext() == null) {
             DialogX.error(ERROR_INIT_TIPS);
             return;
         }
         this.layoutResId = layoutResId;
-        customView = LayoutInflater.from(BaseDialog.getContext()).inflate(layoutResId, new RelativeLayout(BaseDialog.getContext()),false);
+        customView = LayoutInflater.from(BaseDialog.getContext()).inflate(layoutResId, new RelativeLayout(BaseDialog.getContext()), false);
     }
     
     public OnBindView(View customView) {
@@ -56,4 +57,37 @@ public abstract class OnBindView<D> {
         layoutResId = 0;
         customView = null;
     }
+    
+    public OnBindView<D> bindParent(ViewGroup parentView) {
+        if (customView == null) return this;
+        if (customView.getParent() != null) {
+            if (customView.getParent()==parentView){
+                return this;
+            }
+            ((ViewGroup) customView.getParent()).removeView(customView);
+        }
+        ViewGroup.LayoutParams lp = parentView.getLayoutParams();
+        if (lp == null) {
+            lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+        }
+        parentView.addView(customView, lp);
+        return this;
+    }
+    
+    public OnBindView<D> bindParent(ViewGroup parentView, BaseDialog dialog) {
+        if (customView == null) return this;
+        if (customView.getParent() != null) {
+            if (customView.getParent()==parentView){
+                return this;
+            }
+            ((ViewGroup) customView.getParent()).removeView(customView);
+        }
+        ViewGroup.LayoutParams lp = parentView.getLayoutParams();
+        if (lp == null) {
+            lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+        }
+        parentView.addView(customView, lp);
+        onBind((D) dialog, customView);
+        return this;
+    }
 }

+ 3 - 3
README.md

@@ -108,7 +108,7 @@ DialogX 采用了主题分离结构,主框架仅包含 Material 设计风格
 想要在您的项目引入 DialogX,您需要在 app 的 build.gradle 文件中找到 `dependencies{}` 代码块,并在其中加入以下语句:
 
 ```
-implementation 'com.kongzue.dialogx:DialogX:0.0.35'
+implementation 'com.kongzue.dialogx:DialogX:0.0.36'
 ```
 
 ### 方式二:Gradle 引入  jitPack 源
@@ -128,7 +128,7 @@ allprojects {
 2) 在 app 的 build.gradle 文件中找到 `dependencies{}` 代码块,并在其中加入以下语句:
 
 ```
-implementation 'com.github.kongzue.dialogx:DialogX:0.0.35'
+implementation 'com.github.kongzue.dialogx:DialogX:0.0.36'
 ```
 
 ### 方式三:直接引入 AAR 包文件
@@ -155,7 +155,7 @@ implementation(name: 'AAR文件名', ext: 'aar')
 <dependency>
   <groupId>com.kongzue.dialogx</groupId>
   <artifactId>DialogX</artifactId>
-  <version>0.0.35</version>
+  <version>0.0.36</version>
   <type>pom</type>
 </dependency>
 ```

+ 1 - 1
app/build.gradle

@@ -35,7 +35,7 @@ dependencies {
     implementation 'com.kongzue.dialogx.style.kongzue:DialogXKongzueStyle:0.0.35'
     implementation 'com.kongzue.dialogx.style.miui:DialogXMIUIStyle:0.0.35'
 
-    implementation 'com.github.kongzue:DialogXStyle-Snackbar:1.0.3'
+    implementation 'com.github.kongzue:DialogXStyle-Snackbar:1.0.6'
 
     implementation project(path: ':DialogX')
 }

+ 28 - 26
app/src/main/java/com/kongzue/dialogxdemo/App.java

@@ -1,12 +1,14 @@
 package com.kongzue.dialogxdemo;
 
 import android.content.Context;
+import android.graphics.Color;
 
 import com.kongzue.baseframework.BaseApp;
 import com.kongzue.dialogx.DialogX;
 import com.kongzue.dialogx.dialogs.CustomDialog;
 import com.kongzue.dialogx.interfaces.ProgressViewInterface;
 import com.kongzue.dialogx.style.MaterialStyle;
+import com.kongzue.dialogx.util.TextInfo;
 import com.kongzue.dialogx.util.views.ProgressView;
 
 /**
@@ -21,32 +23,32 @@ public class App extends BaseApp<App> {
     public void init() {
         DialogX.init(this);
         DialogX.globalStyle = new MaterialStyle()
-//        {
-//            @Override
-//            public PopTipSettings popTipSettings() {
-//                return new PopTipSettings() {
-//                    @Override
-//                    public int layout(boolean light) {
-//                        return light?R.layout.layout_dialogx_poptip_snackbar:R.layout.layout_dialogx_poptip_snackbar_dark;
-//                    }
-//
-//                    @Override
-//                    public ALIGN align() {
-//                        return ALIGN.BOTTOM;
-//                    }
-//
-//                    @Override
-//                    public int enterAnimResId(boolean light) {
-//                        return com.kongzue.dialogx.R.anim.anim_dialogx_default_enter;
-//                    }
-//
-//                    @Override
-//                    public int exitAnimResId(boolean light) {
-//                        return com.kongzue.dialogx.R.anim.anim_dialogx_default_exit;
-//                    }
-//                };
-//            }
-//        }
+        {
+            @Override
+            public PopTipSettings popTipSettings() {
+                return new PopTipSettings() {
+                    @Override
+                    public int layout(boolean light) {
+                        return light?R.layout.layout_dialogx_poptip_snackbar:R.layout.layout_dialogx_poptip_snackbar_dark;
+                    }
+
+                    @Override
+                    public ALIGN align() {
+                        return ALIGN.BOTTOM;
+                    }
+
+                    @Override
+                    public int enterAnimResId(boolean light) {
+                        return com.kongzue.dialogx.R.anim.anim_dialogx_default_enter;
+                    }
+
+                    @Override
+                    public int exitAnimResId(boolean light) {
+                        return com.kongzue.dialogx.R.anim.anim_dialogx_default_exit;
+                    }
+                };
+            }
+        }
         ;
         DialogX.globalTheme = DialogX.THEME.AUTO;
         DialogX.onlyOnePopTip = false;

+ 25 - 7
app/src/main/java/com/kongzue/dialogxdemo/MainActivity.java

@@ -7,6 +7,7 @@ import android.content.res.Configuration;
 import android.graphics.Color;
 import android.net.Uri;
 import android.os.Handler;
+import android.os.Looper;
 import android.util.Log;
 import android.view.View;
 import android.view.inputmethod.InputMethodManager;
@@ -162,7 +163,19 @@ public class MainActivity extends BaseActivity {
                             runDelayed(new Runnable() {
                                 @Override
                                 public void run() {
-                                    finish();
+                                    new Thread() {
+                                        @Override
+                                        public void run() {
+                                            try {
+                                                //模拟2秒后启动 WaitDialog
+                                                sleep(2000);
+                                                WaitDialog.show(MainActivity.this, "Hello!");
+                                            } catch (Exception e) {
+                                                e.printStackTrace();
+                                            }
+                                        }
+                                    }.start();
+                                    finish();       //先结束掉本界面
                                 }
                             }, 2000);
                             return false;
@@ -243,13 +256,17 @@ public class MainActivity extends BaseActivity {
         btnMessageDialog.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
-                MessageDialog.show("标题", "这里是正文内容。", "确定").setOkButton(new OnDialogButtonClickListener<MessageDialog>() {
+                new Thread() {
                     @Override
-                    public boolean onClick(MessageDialog baseDialog, View v) {
-                        PopTip.show("点击确定按钮");
-                        return false;
+                    public void run() {
+                        try {
+                            sleep(1000);
+                            TipDialog.show("OK", WaitDialog.TYPE.SUCCESS);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
                     }
-                });
+                }.start();
             }
         });
         
@@ -626,7 +643,8 @@ public class MainActivity extends BaseActivity {
                             }
                         });
                     }
-                }).setFullScreen(true)
+                })
+                        .setFullScreen(true)
                         .setMaskColor(getResources().getColor(R.color.black30));
             }
         });

+ 1 - 1
build.gradle

@@ -5,7 +5,7 @@ buildscript {
         jcenter()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:4.1.2'
+        classpath 'com.android.tools.build:gradle:4.1.3'
         classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
         classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
 

+ 2 - 2
gradle.properties

@@ -18,5 +18,5 @@ android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
 
-BUILD_VERSION=0.0.35
-BUILD_VERSION_INT=35
+BUILD_VERSION=0.0.36
+BUILD_VERSION_INT=36