Parcourir la source

0.0.44.beta10
- 针对 CustomDialog 存在的空指针问题进行了修复;
- 针对 WaitDialog 使用自定义布局后,切换至 TipDialog 后自动关闭无效的问题进行了修复;

kongzue il y a 3 ans
Parent
commit
355af97aa9

+ 14 - 10
DialogX/src/main/java/com/kongzue/dialogx/dialogs/CustomDialog.java

@@ -4,6 +4,7 @@ import android.animation.ValueAnimator;
 import android.app.Activity;
 import android.graphics.Color;
 import android.view.View;
+import android.view.ViewGroup;
 import android.view.animation.Animation;
 import android.view.animation.AnimationUtils;
 import android.view.animation.DecelerateInterpolator;
@@ -209,7 +210,7 @@ public class CustomDialog extends BaseDialog {
                         maskEnterAnim.setDuration(enterAnimDurationTemp);
                         boxRoot.startAnimation(maskEnterAnim);
                     }
-    
+                    
                     ValueAnimator bkgAlpha = ValueAnimator.ofFloat(0f, 1f);
                     bkgAlpha.setDuration(enterAnimDurationTemp);
                     bkgAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@@ -228,6 +229,9 @@ public class CustomDialog extends BaseDialog {
         public void refreshView() {
             RelativeLayout.LayoutParams rlp;
             rlp = ((RelativeLayout.LayoutParams) boxCustom.getLayoutParams());
+            if (rlp == null) {
+                rlp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+            }
             switch (align) {
                 case TOP:
                     rlp.removeRule(RelativeLayout.CENTER_IN_PARENT);
@@ -275,7 +279,7 @@ public class CustomDialog extends BaseDialog {
         @Override
         public void doDismiss(View v) {
             if (v != null) v.setEnabled(false);
-            if (!dismissAnimFlag){
+            if (!dismissAnimFlag) {
                 dismissAnimFlag = true;
                 boxCustom.post(new Runnable() {
                     @Override
@@ -287,9 +291,9 @@ public class CustomDialog extends BaseDialog {
                         if (exitAnimResId != 0) {
                             exitAnimResIdTemp = exitAnimResId;
                         }
-            
+                        
                         Animation exitAnim = AnimationUtils.loadAnimation(getContext() == null ? boxCustom.getContext() : getContext(), exitAnimResIdTemp);
-            
+                        
                         long exitAnimDurationTemp = exitAnim.getDuration();
                         if (overrideExitDuration >= 0) {
                             exitAnimDurationTemp = overrideExitDuration;
@@ -301,28 +305,28 @@ public class CustomDialog extends BaseDialog {
                         exitAnim.setAnimationListener(new Animation.AnimationListener() {
                             @Override
                             public void onAnimationStart(Animation animation) {
-                    
+                            
                             }
-                
+                            
                             @Override
                             public void onAnimationEnd(Animation animation) {
                                 dismiss(dialogView);
                             }
-                
+                            
                             @Override
                             public void onAnimationRepeat(Animation animation) {
-                    
+                            
                             }
                         });
                         boxCustom.startAnimation(exitAnim);
-            
+                        
                         if (overrideMaskExitAnimRes != 0) {
                             Animation maskExitAnim = AnimationUtils.loadAnimation(getContext(), overrideMaskExitAnimRes);
                             maskExitAnim.setDuration(exitAnimDurationTemp);
                             maskExitAnim.setInterpolator(new DecelerateInterpolator(2f));
                             boxRoot.startAnimation(maskExitAnim);
                         }
-            
+                        
                         ValueAnimator bkgAlpha = ValueAnimator.ofFloat(1f, 0f);
                         bkgAlpha.setDuration(exitAnimDurationTemp);
                         bkgAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

+ 30 - 15
DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java

@@ -553,24 +553,39 @@ public class WaitDialog extends BaseDialog {
                             break;
                     }
                     
-                    //此事件是在完成衔接动画绘制后执行的逻辑
-                    progressView.whenShowTick(new Runnable() {
-                        @Override
-                        public void run() {
-                            getDialogLifecycleCallback().onShow(WaitDialog.this);
-                            refreshView();
-                            if (tipShowDuration > 0) {
-                                ((View) progressView).postDelayed(new Runnable() {
-                                    @Override
-                                    public void run() {
-                                        if (showType > -1) {
-                                            doDismiss(null);
+                    if (boxProgress != null && boxProgress.getVisibility() == View.VISIBLE) {
+                        //此事件是在完成衔接动画绘制后执行的逻辑
+                        progressView.whenShowTick(new Runnable() {
+                            @Override
+                            public void run() {
+                                getDialogLifecycleCallback().onShow(WaitDialog.this);
+                                refreshView();
+                                if (tipShowDuration > 0) {
+                                    ((View) progressView).postDelayed(new Runnable() {
+                                        @Override
+                                        public void run() {
+                                            if (showType > -1) {
+                                                doDismiss(null);
+                                            }
                                         }
-                                    }
-                                }, tipShowDuration);
+                                    }, tipShowDuration);
+                                }
                             }
+                        });
+                    } else {
+                        getDialogLifecycleCallback().onShow(WaitDialog.this);
+                        refreshView();
+                        if (tipShowDuration > 0) {
+                            runOnMainDelay(new Runnable() {
+                                @Override
+                                public void run() {
+                                    if (showType > -1) {
+                                        doDismiss(null);
+                                    }
+                                }
+                            }, tipShowDuration);
                         }
-                    });
+                    }
                 }
             });
         }

+ 1 - 1
gradle.properties

@@ -18,5 +18,5 @@ android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
 
-BUILD_VERSION=0.0.44.beta9
+BUILD_VERSION=0.0.44.beta10
 BUILD_VERSION_INT=43