瀏覽代碼

0.0.45.beta7

kongzue 2 年之前
父節點
當前提交
50e94b2c96

+ 25 - 11
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomDialog.java

@@ -60,6 +60,7 @@ public class BottomDialog extends BaseDialog {
     protected OnDialogButtonClickListener<BottomDialog> okButtonClickListener;
     protected OnDialogButtonClickListener<BottomDialog> otherButtonClickListener;
     protected BOOLEAN privateCancelable;
+    protected boolean bkgInterceptTouch = true;
     
     protected TextInfo titleTextInfo;
     protected TextInfo messageTextInfo;
@@ -418,13 +419,13 @@ public class BottomDialog extends BaseDialog {
                     float customDialogTop = 0;
                     if (bottomDialogMaxHeight > 0 && bottomDialogMaxHeight <= 1) {
                         customDialogTop = boxBkg.getHeight() - bottomDialogMaxHeight * boxBkg.getHeight();
-                    } else if (bottomDialogMaxHeight>1){
+                    } else if (bottomDialogMaxHeight > 1) {
                         customDialogTop = boxBkg.getHeight() - bottomDialogMaxHeight;
                     }
                     
                     //上移动画
                     ObjectAnimator enterAnim = ObjectAnimator.ofFloat(boxBkg, "y", boxBkg.getY(),
-                            boxRoot.getUnsafePlace().top + customDialogTop
+                            bkgEnterAimY = boxRoot.getUnsafePlace().top + customDialogTop
                     );
                     if (overrideEnterDuration >= 0) {
                         enterAnimDurationTemp = overrideEnterDuration;
@@ -481,15 +482,19 @@ public class BottomDialog extends BaseDialog {
             useTextInfo(btnSelectOther, otherTextInfo);
             useTextInfo(btnSelectPositive, okTextInfo);
             
-            if (isCancelable()) {
-                boxRoot.setOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        doDismiss(v);
-                    }
-                });
+            if (bkgInterceptTouch) {
+                if (isCancelable()) {
+                    boxRoot.setOnClickListener(new View.OnClickListener() {
+                        @Override
+                        public void onClick(View v) {
+                            doDismiss(v);
+                        }
+                    });
+                } else {
+                    boxRoot.setOnClickListener(null);
+                }
             } else {
-                boxRoot.setOnClickListener(null);
+                boxRoot.setClickable(false);
             }
             boxBkg.setOnClickListener(new View.OnClickListener() {
                 @Override
@@ -603,7 +608,7 @@ public class BottomDialog extends BaseDialog {
                 if (exitAnimDuration >= 0) {
                     exitAnimDurationTemp = exitAnimDuration;
                 }
-                ObjectAnimator exitAnim = ObjectAnimator.ofFloat(bkg, "y", bkg.getY(), bkgEnterAimY);
+                ObjectAnimator exitAnim = ObjectAnimator.ofFloat(boxBkg, "y", boxBkg.getY(), boxBkg.getHeight());
                 exitAnim.setDuration(exitAnimDurationTemp);
                 exitAnim.start();
             }
@@ -985,4 +990,13 @@ public class BottomDialog extends BaseDialog {
         this.dialogImplMode = dialogImplMode;
         return this;
     }
+    
+    public boolean isBkgInterceptTouch() {
+        return bkgInterceptTouch;
+    }
+    
+    public BottomDialog setBkgInterceptTouch(boolean bkgInterceptTouch) {
+        this.bkgInterceptTouch = bkgInterceptTouch;
+        return this;
+    }
 }

+ 9 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomMenu.java

@@ -1116,4 +1116,13 @@ public class BottomMenu extends BottomDialog {
         this.menuItemTextInfoInterceptor = menuItemTextInfoInterceptor;
         return this;
     }
+    
+    public boolean isBkgInterceptTouch() {
+        return bkgInterceptTouch;
+    }
+    
+    public BottomMenu setBkgInterceptTouch(boolean bkgInterceptTouch) {
+        this.bkgInterceptTouch = bkgInterceptTouch;
+        return this;
+    }
 }

+ 23 - 9
DialogX/src/main/java/com/kongzue/dialogx/dialogs/CustomDialog.java

@@ -49,6 +49,7 @@ public class CustomDialog extends BaseDialog {
     private View dialogView;
     protected int maskColor = Color.TRANSPARENT;
     protected BOOLEAN privateCancelable;
+    protected boolean bkgInterceptTouch = true;
     
     public enum ALIGN {
         CENTER,
@@ -265,15 +266,19 @@ public class CustomDialog extends BaseDialog {
             boxCustom.setLayoutParams(rlp);
             
             boxRoot.setAutoUnsafePlacePadding(autoUnsafePlacePadding);
-            if (isCancelable()) {
-                boxRoot.setOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        doDismiss(v);
-                    }
-                });
-            } else {
-                boxRoot.setOnClickListener(null);
+            if (bkgInterceptTouch) {
+                if (isCancelable()) {
+                    boxRoot.setOnClickListener(new View.OnClickListener() {
+                        @Override
+                        public void onClick(View v) {
+                            doDismiss(v);
+                        }
+                    });
+                } else {
+                    boxRoot.setOnClickListener(null);
+                }
+            }else{
+                boxRoot.setClickable(false);
             }
             
             if (onBindView != null && onBindView.getCustomView() != null) {
@@ -549,4 +554,13 @@ public class CustomDialog extends BaseDialog {
         this.dialogImplMode = dialogImplMode;
         return this;
     }
+    
+    public boolean isBkgInterceptTouch() {
+        return bkgInterceptTouch;
+    }
+    
+    public CustomDialog setBkgInterceptTouch(boolean bkgInterceptTouch) {
+        this.bkgInterceptTouch = bkgInterceptTouch;
+        return this;
+    }
 }

+ 9 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/InputDialog.java

@@ -579,4 +579,13 @@ public class InputDialog extends MessageDialog {
         this.dialogImplMode = dialogImplMode;
         return this;
     }
+    
+    public boolean isBkgInterceptTouch() {
+        return bkgInterceptTouch;
+    }
+    
+    public InputDialog setBkgInterceptTouch(boolean bkgInterceptTouch) {
+        this.bkgInterceptTouch = bkgInterceptTouch;
+        return this;
+    }
 }

+ 23 - 9
DialogX/src/main/java/com/kongzue/dialogx/dialogs/MessageDialog.java

@@ -54,6 +54,7 @@ public class MessageDialog extends BaseDialog {
     public static int overrideEnterAnimRes = 0;
     public static int overrideExitAnimRes = 0;
     public static BOOLEAN overrideCancelable;
+    protected boolean bkgInterceptTouch = true;
     protected OnBindView<MessageDialog> onBindView;
     protected MessageDialog me = this;
     protected BOOLEAN privateCancelable;
@@ -379,7 +380,7 @@ public class MessageDialog extends BaseDialog {
                 @Override
                 public boolean onBackPressed() {
                     if (onBackPressedListener != null) {
-                        if (onBackPressedListener.onBackPressed()){
+                        if (onBackPressedListener.onBackPressed()) {
                             dismiss();
                         }
                         return false;
@@ -640,15 +641,19 @@ public class MessageDialog extends BaseDialog {
             }
             
             //Events
-            if (isCancelable()) {
-                boxRoot.setOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        doDismiss(v);
-                    }
-                });
+            if (bkgInterceptTouch) {
+                if (isCancelable()) {
+                    boxRoot.setOnClickListener(new View.OnClickListener() {
+                        @Override
+                        public void onClick(View v) {
+                            doDismiss(v);
+                        }
+                    });
+                } else {
+                    boxRoot.setOnClickListener(null);
+                }
             } else {
-                boxRoot.setOnClickListener(null);
+                boxRoot.setClickable(false);
             }
             
             if (onBindView != null && onBindView.getCustomView() != null) {
@@ -1118,4 +1123,13 @@ public class MessageDialog extends BaseDialog {
         this.dialogImplMode = dialogImplMode;
         return this;
     }
+    
+    public boolean isBkgInterceptTouch() {
+        return bkgInterceptTouch;
+    }
+    
+    public MessageDialog setBkgInterceptTouch(boolean bkgInterceptTouch) {
+        this.bkgInterceptTouch = bkgInterceptTouch;
+        return this;
+    }
 }

+ 23 - 8
DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopMenu.java

@@ -55,6 +55,7 @@ public class PopMenu extends BaseDialog {
     public static long overrideExitDuration = -1;
     
     protected PopMenu me = this;
+    protected boolean bkgInterceptTouch = true;
     protected OnBindView<PopMenu> onBindView;                               //自定义布局
     protected DialogLifecycleCallback<PopMenu> dialogLifecycleCallback;     //对话框生命周期
     protected View dialogView;
@@ -554,15 +555,20 @@ public class PopMenu extends BaseDialog {
             } else {
                 menuListAdapter.notifyDataSetChanged();
             }
-            if (isCancelable()) {
-                boxRoot.setOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        doDismiss(v);
-                    }
-                });
+            
+            if (bkgInterceptTouch) {
+                if (isCancelable()) {
+                    boxRoot.setOnClickListener(new View.OnClickListener() {
+                        @Override
+                        public void onClick(View v) {
+                            doDismiss(v);
+                        }
+                    });
+                } else {
+                    boxRoot.setOnClickListener(null);
+                }
             } else {
-                boxRoot.setOnClickListener(null);
+                boxRoot.setClickable(false);
             }
             
             if (onBindView != null && onBindView.getCustomView() != null) {
@@ -883,4 +889,13 @@ public class PopMenu extends BaseDialog {
         this.offScreen = offScreen;
         return this;
     }
+    
+    public boolean isBkgInterceptTouch() {
+        return bkgInterceptTouch;
+    }
+    
+    public PopMenu setBkgInterceptTouch(boolean bkgInterceptTouch) {
+        this.bkgInterceptTouch = bkgInterceptTouch;
+        return this;
+    }
 }

+ 9 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/TipDialog.java

@@ -165,4 +165,13 @@ public class TipDialog extends WaitDialog {
         this.dialogImplMode = dialogImplMode;
         return this;
     }
+    
+    public boolean isBkgInterceptTouch() {
+        return bkgInterceptTouch;
+    }
+    
+    public TipDialog setBkgInterceptTouch(boolean bkgInterceptTouch) {
+        this.bkgInterceptTouch = bkgInterceptTouch;
+        return this;
+    }
 }

+ 25 - 11
DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java

@@ -49,6 +49,7 @@ public class WaitDialog extends BaseDialog {
     public static int overrideEnterAnimRes = 0;
     public static int overrideExitAnimRes = 0;
     public static BOOLEAN overrideCancelable;
+    protected boolean bkgInterceptTouch = true;
     protected OnBindView<WaitDialog> onBindView;
     protected int customEnterAnimResId;
     protected int customExitAnimResId;
@@ -400,17 +401,6 @@ public class WaitDialog extends BaseDialog {
                     return false;
                 }
             });
-            
-            if (isCancelable()) {
-                boxRoot.setOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        doDismiss(v);
-                    }
-                });
-            } else {
-                boxRoot.setOnClickListener(null);
-            }
         }
         
         private float oldProgress;
@@ -470,6 +460,21 @@ public class WaitDialog extends BaseDialog {
                 boxCustomView.setVisibility(View.GONE);
                 boxProgress.setVisibility(View.VISIBLE);
             }
+            
+            if (bkgInterceptTouch) {
+                if (isCancelable()) {
+                    boxRoot.setOnClickListener(new View.OnClickListener() {
+                        @Override
+                        public void onClick(View v) {
+                            doDismiss(v);
+                        }
+                    });
+                } else {
+                    boxRoot.setOnClickListener(null);
+                }
+            } else {
+                boxRoot.setClickable(false);
+            }
         }
         
         public void doDismiss(final View v) {
@@ -968,4 +973,13 @@ public class WaitDialog extends BaseDialog {
         this.dialogImplMode = dialogImplMode;
         return this;
     }
+    
+    public boolean isBkgInterceptTouch() {
+        return bkgInterceptTouch;
+    }
+    
+    public WaitDialog setBkgInterceptTouch(boolean bkgInterceptTouch) {
+        this.bkgInterceptTouch = bkgInterceptTouch;
+        return this;
+    }
 }

+ 1 - 1
DialogX/src/main/java/com/kongzue/dialogx/util/BottomDialogTouchEventInterceptor.java

@@ -112,7 +112,7 @@ public class BottomDialogTouchEventInterceptor {
                             } else {
                                 if (impl.boxBkg.getY() > bkgOldY + dip2px(35)) {
                                     impl.preDismiss();
-                                } else {
+                                } else if (impl.boxBkg.getY() < bkgOldY - dip2px(5)) {
                                     ObjectAnimator enterAnim = ObjectAnimator.ofFloat(impl.boxBkg, "y", impl.boxBkg.getY(), impl.boxRoot.getUnsafePlace().top);
                                     enterAnim.setDuration(300);
                                     enterAnim.start();

+ 1 - 1
gradle.properties

@@ -19,5 +19,5 @@ android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
 
-BUILD_VERSION=0.0.45.beta6
+BUILD_VERSION=0.0.45.beta7
 BUILD_VERSION_INT=44