1
0
kongzue 3 жил өмнө
parent
commit
b1d4e5a774

+ 22 - 6
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomDialog.java

@@ -21,6 +21,7 @@ import android.widget.TextView;
 
 import androidx.annotation.ColorInt;
 import androidx.annotation.ColorRes;
+import androidx.core.view.ViewCompat;
 
 import com.kongzue.dialogx.DialogX;
 import com.kongzue.dialogx.R;
@@ -38,6 +39,8 @@ import com.kongzue.dialogx.util.views.BlurView;
 import com.kongzue.dialogx.util.views.DialogXBaseRelativeLayout;
 import com.kongzue.dialogx.util.views.MaxRelativeLayout;
 
+import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_CLICK;
+
 /**
  * @author: Kongzue
  * @github: https://github.com/kongzue/
@@ -394,6 +397,7 @@ public class BottomDialog extends BaseDialog {
             boxRoot.post(new Runnable() {
                 @Override
                 public void run() {
+                    long enterAnimDurationTemp = 300;
                     /**
                      * 对于非支持滑动展开的对话框,直接使用从下往上的资源动画实现
                      * 其他情况不适用,请参考 onContentViewLayoutChangeListener 的代码实现。
@@ -401,7 +405,7 @@ public class BottomDialog extends BaseDialog {
                     if (style.overrideBottomDialogRes() == null || !style.overrideBottomDialogRes().touchSlide()) {
                         //bkg.setY(getRootFrameLayout().getMeasuredHeight());
                         Animation enterAnim = AnimationUtils.loadAnimation(getContext(), R.anim.anim_dialogx_bottom_enter);
-                        long enterAnimDurationTemp = enterAnim.getDuration();
+                        enterAnimDurationTemp = enterAnim.getDuration();
                         if (overrideEnterDuration >= 0) {
                             enterAnimDurationTemp = overrideEnterDuration;
                         }
@@ -410,19 +414,31 @@ public class BottomDialog extends BaseDialog {
                         }
                         enterAnim.setDuration(enterAnimDurationTemp);
                         enterAnim.setInterpolator(new DecelerateInterpolator(2f));
-                        bkg.startAnimation(enterAnim);
-        
+                        
                         bkg.setY(bkgEnterAimY);
+                        bkg.startAnimation(enterAnim);
                     }
     
                     boxRoot.animate()
-                            .setDuration(300)
+                            .setDuration(enterAnimDurationTemp)
                             .alpha(1f)
                             .setInterpolator(new DecelerateInterpolator())
                             .setListener(null);
+    
+                    bkg.postDelayed(new Runnable() {
+                        @Override
+                        public void run() {
+                            isEnterAnimFinished = true;
+    
+                            bkg.setFocusable(true);
+                            bkg.requestFocus();
+                        }
+                    },enterAnimDurationTemp);
                 }
             });
         }
+        
+        private boolean isEnterAnimFinished = false;
     
         private ViewTreeObserver.OnGlobalLayoutListener onContentViewLayoutChangeListener = new ViewTreeObserver.OnGlobalLayoutListener() {
             @Override
@@ -432,7 +448,7 @@ public class BottomDialog extends BaseDialog {
                         //若内容布已经超出屏幕可用范围,且预设的对话框最大高度已知
                         if (bkg.isChildScrollViewCanScroll() && bottomDialogMaxHeight != 0) {
                             //先将内容布局放置到屏幕底部以外区域,然后执行上移动画
-                            bkg.setY(getRootFrameLayout().getMeasuredHeight());
+                            if (!isEnterAnimFinished)bkg.setY(getRootFrameLayout().getMeasuredHeight());
                             //执行上移动画
                             if (bottomDialogMaxHeight <= 1) {
                                 //bottomDialogMaxHeight 值若为小于 1 的小数,视为比例
@@ -453,7 +469,7 @@ public class BottomDialog extends BaseDialog {
                             keepBottomAnim.start();
                         } else {
                             bkgEnterAimY = boxBkg.getHeight() - bkg.getHeight();
-                            bkg.setY(boxRoot.getHeight());
+                            if (!isEnterAnimFinished)bkg.setY(boxRoot.getHeight());
                             bkg.post(new Runnable() {
                                 @Override
                                 public void run() {

+ 3 - 1
DialogX/src/main/java/com/kongzue/dialogx/impl/ActivityLifecycleImpl.java

@@ -4,10 +4,12 @@ import android.app.Activity;
 import android.app.Application;
 import android.content.Context;
 import android.os.Bundle;
+import android.os.Looper;
 import android.util.Log;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
 
 import com.kongzue.dialogx.interfaces.BaseDialog;
 
@@ -75,7 +77,7 @@ public class ActivityLifecycleImpl implements Application.ActivityLifecycleCallb
     }
     
     @Override
-    public void onActivityPreDestroyed(@NonNull Activity activity) {
+    public void onActivityPreDestroyed(@NonNull final Activity activity) {
         BaseDialog.recycleDialog(activity);
     }
     

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

@@ -39,22 +39,6 @@ public class WindowUtil {
         ;
         if (!touchEnable) {
             layoutParams.flags = layoutParams.flags | FLAG_NOT_FOCUSABLE;
-
-//            ViewGroup boxRoot = dialogView.findViewById(R.id.box_root);
-//            ViewGroup boxBody = dialogView.findViewById(R.id.box_body);
-//            if (boxBody != null && boxRoot != null) {
-//                boxRoot.removeView(boxBody);
-//                dialogView = boxBody;
-//
-//                layoutParams.width = 300;
-//                layoutParams.height = 85;
-//            }
-//            int paddingValue = (int) boxBody.getElevation();
-//            layoutParams.width = WRAP_CONTENT;
-//            layoutParams.height = WRAP_CONTENT;
-//            boxRoot.setPadding(100, 0, 100, 100);
-
-//            boxRoot.setFocusable(false);
         }
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
             layoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
@@ -67,7 +51,7 @@ public class WindowUtil {
         BaseDialog baseDialog = (BaseDialog) dialogView.getTag();
         if (baseDialog != null && baseDialog.getActivity() != null) {
             WindowManager manager = (WindowManager) baseDialog.getActivity().getSystemService(Context.WINDOW_SERVICE);
-            manager.removeView(dialogView);
+            manager.removeViewImmediate(dialogView);
         }
     }
 }

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

@@ -24,7 +24,7 @@ public class App extends BaseApp<App> {
     @Override
     public void init() {
         DialogX.init(this);
-        DialogX.implIMPLMode= DialogX.IMPL_MODE.VIEW;
+        DialogX.implIMPLMode= DialogX.IMPL_MODE.WINDOW;
         DialogX.globalStyle = new MaterialStyle() {
             @Override
             public PopTipSettings popTipSettings() {

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

@@ -644,7 +644,7 @@ public class MainActivity extends BaseActivity {
                         });
                     }
                 })
-                        .setAlign(CustomDialog.ALIGN.CENTER)
+                        .setAlign(CustomDialog.ALIGN.LEFT)
                         .setMaskColor(getResources().getColor(R.color.black30));
             }
         });

+ 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.37.alpha7
+BUILD_VERSION=0.0.37.alpha8
 BUILD_VERSION_INT=37