Jelajahi Sumber

0.0.48.beta32
- 修复上一个版本中 MaterialYou 主题的等待对话框圆角异常问题;
- 修复 FullScreenDialog 在使用 Fragment 作为容器时,Fragment 的内容布局高度 match_parent 不生效的问题;

Kongzue 2 tahun lalu
induk
melakukan
a1e91e007d

+ 0 - 1
.idea/misc.xml

@@ -1,4 +1,3 @@
-<?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="DesignSurface">
     <option name="filePathToZoomLevelMap">

+ 25 - 23
DialogX/src/main/java/com/kongzue/dialogx/interfaces/OnBindView.java

@@ -9,8 +9,10 @@ import android.widget.RelativeLayout;
 
 import com.kongzue.dialogx.DialogX;
 import com.kongzue.dialogx.R;
+import com.kongzue.dialogx.util.views.ExtendChildLayoutParamsFrameLayout;
 
 import static com.kongzue.dialogx.DialogX.ERROR_INIT_TIPS;
+import static com.kongzue.dialogx.interfaces.BaseDialog.log;
 
 import androidx.appcompat.app.AppCompatActivity;
 
@@ -25,10 +27,10 @@ import java.util.Random;
  * @createTime: 2020/10/8 17:00
  */
 public abstract class OnBindView<D> {
-    
+
     int layoutResId;
     View customView;
-    
+
     public OnBindView(int layoutResId) {
         if (BaseDialog.getTopActivity() == null) {
             DialogX.error(ERROR_INIT_TIPS);
@@ -37,7 +39,7 @@ public abstract class OnBindView<D> {
         this.layoutResId = layoutResId;
         customView = LayoutInflater.from(BaseDialog.getTopActivity()).inflate(layoutResId, new RelativeLayout(BaseDialog.getTopActivity()), false);
     }
-    
+
     public OnBindView(int layoutResId, boolean async) {
         if (BaseDialog.getTopActivity() == null) {
             DialogX.error(ERROR_INIT_TIPS);
@@ -62,22 +64,22 @@ public abstract class OnBindView<D> {
             customView = LayoutInflater.from(BaseDialog.getTopActivity()).inflate(layoutResId, new RelativeLayout(BaseDialog.getTopActivity()), false);
         }
     }
-    
+
     public OnBindView(View customView) {
         this.customView = customView;
     }
-    
+
     private androidx.fragment.app.Fragment fragment;
     private android.app.Fragment supportFragment;
     private int fragmentParentId = View.NO_ID;
-    
+
     private int getFragmentParentId() {
         if (fragmentParentId == View.NO_ID) {
             fragmentParentId = createFragmentParentId();
         }
         return fragmentParentId;
     }
-    
+
     private int createFragmentParentId() {
         fragmentParentId = new Random().nextInt();
         View somebodyView = BaseDialog.getTopActivity().findViewById(fragmentParentId);
@@ -86,57 +88,57 @@ public abstract class OnBindView<D> {
         }
         return fragmentParentId;
     }
-    
+
     public OnBindView(androidx.fragment.app.Fragment fragment) {
         if (BaseDialog.getTopActivity() == null) return;
-        this.customView = new FrameLayout(BaseDialog.getTopActivity());
+        this.customView = new ExtendChildLayoutParamsFrameLayout(BaseDialog.getTopActivity());
         this.customView.setId(getFragmentParentId());
         this.fragment = fragment;
         this.supportFragment = null;
     }
-    
+
     public OnBindView(android.app.Fragment supportFragment) {
         if (BaseDialog.getTopActivity() == null) return;
-        this.customView = new FrameLayout(BaseDialog.getTopActivity());
+        this.customView = new ExtendChildLayoutParamsFrameLayout(BaseDialog.getTopActivity());
         this.customView.setId(getFragmentParentId());
         this.supportFragment = supportFragment;
         this.fragment = null;
     }
-    
+
     public abstract void onBind(D dialog, View v);
-    
+
     public void onFragmentBind(D dialog, View frameLayout, androidx.fragment.app.Fragment fragment, androidx.fragment.app.FragmentManager fragmentManager) {
     }
-    
+
     public void onFragmentBind(D dialog, View frameLayout, android.app.Fragment fragment, android.app.FragmentManager fragmentManager) {
     }
-    
+
     public int getLayoutResId() {
         return layoutResId;
     }
-    
+
     public OnBindView<D> setLayoutResId(int layoutResId) {
         this.layoutResId = layoutResId;
         return this;
     }
-    
+
     public View getCustomView() {
         if (customView == null) {
             customView = LayoutInflater.from(BaseDialog.getTopActivity()).inflate(layoutResId, new RelativeLayout(BaseDialog.getTopActivity()), false);
         }
         return customView;
     }
-    
+
     public OnBindView<D> setCustomView(View customView) {
         this.customView = customView;
         return this;
     }
-    
+
     public void clean() {
         layoutResId = 0;
         customView = null;
     }
-    
+
     @Deprecated
     public void bindParent(ViewGroup parentView) {
         if (getCustomView() == null) {
@@ -155,7 +157,7 @@ public abstract class OnBindView<D> {
         }
         parentView.addView(getCustomView(), lp);
     }
-    
+
     public void bindParent(ViewGroup parentView, BaseDialog dialog) {
         if (getCustomView() == null) {
             waitBind(parentView, null);
@@ -200,9 +202,9 @@ public abstract class OnBindView<D> {
             });
         }
     }
-    
+
     private Runnable waitBindRunnable;
-    
+
     private void waitBind(ViewGroup parentView, BaseDialog dialog) {
         waitBindRunnable = new Runnable() {
             @Override

+ 31 - 0
DialogX/src/main/java/com/kongzue/dialogx/util/views/ExtendChildLayoutParamsFrameLayout.java

@@ -0,0 +1,31 @@
+package com.kongzue.dialogx.util.views;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.RelativeLayout;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+public class ExtendChildLayoutParamsFrameLayout extends FrameLayout {
+    public ExtendChildLayoutParamsFrameLayout(@NonNull Context context) {
+        super(context);
+    }
+
+    public ExtendChildLayoutParamsFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public ExtendChildLayoutParamsFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+    }
+
+    @Override
+    public void addView(View child, int index, ViewGroup.LayoutParams params) {
+        setLayoutParams(new RelativeLayout.LayoutParams(params.width, params.height));
+        super.addView(child, index, params);
+    }
+}

+ 1 - 7
DialogXMaterialYou/src/main/java/com/kongzue/dialogxmaterialyou/style/MaterialYouStyle.java

@@ -1,7 +1,6 @@
 package com.kongzue.dialogxmaterialyou.style;
 
 import android.content.Context;
-import android.content.res.Resources;
 
 import com.kongzue.dialogx.interfaces.DialogXStyle;
 import com.kongzue.dialogx.interfaces.ProgressViewInterface;
@@ -118,7 +117,7 @@ public class MaterialYouStyle extends DialogXStyle {
 
         @Override
         public int overrideRadiusPx() {
-            return dip2px(50);
+            return -1;
         }
 
         @Override
@@ -141,11 +140,6 @@ public class MaterialYouStyle extends DialogXStyle {
             return new ProgressView(context);
         }
     }
-
-    private int dip2px(float dpValue) {
-        final float scale = Resources.getSystem().getDisplayMetrics().density;
-        return (int) (dpValue * scale + 0.5f);
-    }
     
     @Override
     public BottomDialogRes overrideBottomDialogRes() {

+ 1 - 1
gradle.properties

@@ -19,7 +19,7 @@ android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
 
-BUILD_VERSION=0.0.48.beta31
+BUILD_VERSION=0.0.48.beta32
 BUILD_VERSION_INT=47
 DIALOGX_STYLE_VERSION=5
 android.nonTransitiveRClass=true