Browse Source

0.0.41.beta4

kongzue 3 years ago
parent
commit
323837cc05

+ 40 - 4
DialogX/src/main/java/com/kongzue/dialogx/dialogs/FullScreenDialog.java

@@ -46,6 +46,7 @@ public class FullScreenDialog extends BaseDialog {
     
     protected OnBindView<FullScreenDialog> onBindView;
     protected BOOLEAN privateCancelable;
+    protected boolean hideZoomBackground;
     
     protected DialogLifecycleCallback<FullScreenDialog> dialogLifecycleCallback;
     
@@ -114,6 +115,14 @@ public class FullScreenDialog extends BaseDialog {
             boxBkg = convertView.findViewById(R.id.box_bkg);
             bkg = convertView.findViewById(R.id.bkg);
             boxCustom = convertView.findViewById(R.id.box_custom);
+            
+            if (hideZoomBackground) {
+                dialogView.setBackgroundResource(R.color.black20);
+                imgZoomActivity.setVisibility(View.GONE);
+            } else {
+                dialogView.setBackgroundResource(R.color.black);
+                imgZoomActivity.setVisibility(View.VISIBLE);
+            }
             init();
             dialogImpl = this;
             refreshView();
@@ -164,15 +173,22 @@ public class FullScreenDialog extends BaseDialog {
                 enterAnimDurationTemp = enterAnimDuration;
             }
             
+            bkg.setY(boxRoot.getHeight());
             boxRoot.post(new Runnable() {
                 @Override
                 public void run() {
                     bkgEnterAimY = boxRoot.getSafeHeight() - boxCustom.getHeight();
                     if (bkgEnterAimY < 0) bkgEnterAimY = 0;
+                    boxRoot.animate()
+                            .setDuration(enterAnimDurationTemp)
+                            .alpha(1f)
+                            .setInterpolator(new DecelerateInterpolator())
+                            .setListener(null);
                     
                     ObjectAnimator exitAnim = ObjectAnimator.ofFloat(bkg, "y", boxRoot.getHeight(), bkgEnterAimY);
                     exitAnim.setDuration(enterAnimDurationTemp);
                     exitAnim.start();
+                    bkg.setVisibility(View.VISIBLE);
                 }
             });
             
@@ -181,10 +197,12 @@ public class FullScreenDialog extends BaseDialog {
                 public void y(float y) {
                     float zoomScale = 1 - (boxRoot.getHeight() - y) * 0.00002f;
                     if (zoomScale > 1) zoomScale = 1;
-                    imgZoomActivity.setScaleX(zoomScale);
-                    imgZoomActivity.setScaleY(zoomScale);
-                    
-                    imgZoomActivity.setRadius(dip2px(15) * ((boxRoot.getHeight() - y) / boxRoot.getHeight()));
+                    if (!hideZoomBackground) {
+                        imgZoomActivity.setScaleX(zoomScale);
+                        imgZoomActivity.setScaleY(zoomScale);
+                        
+                        imgZoomActivity.setRadius(dip2px(15) * ((boxRoot.getHeight() - y) / boxRoot.getHeight()));
+                    }
                 }
             });
             
@@ -226,6 +244,14 @@ public class FullScreenDialog extends BaseDialog {
                 });
             }
             
+            if (hideZoomBackground) {
+                dialogView.setBackgroundResource(R.color.black20);
+                imgZoomActivity.setVisibility(View.GONE);
+            } else {
+                dialogView.setBackgroundResource(R.color.black);
+                imgZoomActivity.setVisibility(View.VISIBLE);
+            }
+            
             fullScreenDialogTouchEventInterceptor.refresh(me, this);
         }
         
@@ -394,6 +420,16 @@ public class FullScreenDialog extends BaseDialog {
         return this;
     }
     
+    public boolean isHideZoomBackground() {
+        return hideZoomBackground;
+    }
+    
+    public FullScreenDialog setHideZoomBackground(boolean hideZoomBackground) {
+        this.hideZoomBackground = hideZoomBackground;
+        refreshUI();
+        return this;
+    }
+    
     @Override
     public void onUIModeChange(Configuration newConfig) {
         if (dialogView != null) {

+ 4 - 1
DialogX/src/main/java/com/kongzue/dialogx/impl/DialogFragmentImpl.java

@@ -19,6 +19,9 @@ import androidx.fragment.app.DialogFragment;
 import androidx.fragment.app.FragmentManager;
 import androidx.fragment.app.FragmentTransaction;
 
+import com.kongzue.dialogx.R;
+import com.kongzue.dialogx.dialogs.BottomDialog;
+import com.kongzue.dialogx.dialogs.FullScreenDialog;
 import com.kongzue.dialogx.dialogs.PopTip;
 import com.kongzue.dialogx.interfaces.BaseDialog;
 
@@ -65,7 +68,7 @@ public class DialogFragmentImpl extends DialogFragment {
         Window dialogWindow = getDialog().getWindow();
         if (dialogWindow == null) return;
         dialogWindow.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
-    
+        
         dialogWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
         
         WindowManager.LayoutParams lp = dialogWindow.getAttributes();

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

@@ -164,6 +164,7 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
         if (onLifecycleCallBack != null) {
             onLifecycleCallBack.onDismiss();
         }
+        onSafeInsetsChangeListener = null;
         super.onDetachedFromWindow();
     }
     
@@ -246,4 +247,6 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
         super.onConfigurationChanged(newConfig);
         getParentDialog().onUIModeChange(newConfig);
     }
+    
+    
 }

+ 1 - 0
DialogX/src/main/res/layout/layout_dialogx_fullscreen.xml

@@ -25,6 +25,7 @@
 
             <com.kongzue.dialogx.util.views.MaxRelativeLayout
                 android:id="@+id/bkg"
+                android:visibility="invisible"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:layout_alignParentBottom="true"

+ 1 - 0
DialogX/src/main/res/layout/layout_dialogx_fullscreen_dark.xml

@@ -25,6 +25,7 @@
 
             <com.kongzue.dialogx.util.views.MaxRelativeLayout
                 android:id="@+id/bkg"
+                android:visibility="gone"
                 android:layout_width="wrap_content"
                 android:layout_height="match_parent"
                 android:layout_alignParentBottom="true"

+ 5 - 0
DialogX/src/main/res/values/styles.xml

@@ -8,4 +8,9 @@
         <item name="android:padding">0dp</item>
         <item name="android:windowBackground">@android:color/transparent</item>
     </style>
+
+    <style name="DialogXBottomMenuAnim">
+        <item name="android:windowEnterAnimation">@anim/anim_dialogx_bottom_enter</item>
+        <item name="android:windowExitAnimation">@anim/anim_dialogx_bottom_exit</item>
+    </style>
 </resources>

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

@@ -423,48 +423,55 @@ public class MainActivity extends BaseActivity {
             public void onClick(View v) {
                 if (rdoMaterial.isChecked()) {
                     //Material 可滑动展开 BottomMenu 演示
-                    BottomMenu.show(new String[]{"添加", "查看", "编辑", "删除", "分享", "评论", "下载", "收藏", "赞!", "不喜欢", "所属专辑", "复制链接", "类似推荐", "添加", "查看", "编辑", "删除", "分享", "评论", "下载", "收藏", "赞!", "不喜欢", "所属专辑", "复制链接", "类似推荐"})
-                            .setOnIconChangeCallBack(new OnIconChangeCallBack(true) {
-                                @Override
-                                public int getIcon(BottomMenu bottomMenu, int index, String menuText) {
-                                    switch (menuText) {
-                                        case "添加":
-                                            return R.mipmap.img_dialogx_demo_add;
-                                        case "查看":
-                                            return R.mipmap.img_dialogx_demo_view;
-                                        case "编辑":
-                                            return R.mipmap.img_dialogx_demo_edit;
-                                        case "删除":
-                                            return R.mipmap.img_dialogx_demo_delete;
-                                        case "分享":
-                                            return R.mipmap.img_dialogx_demo_share;
-                                        case "评论":
-                                            return R.mipmap.img_dialogx_demo_comment;
-                                        case "下载":
-                                            return R.mipmap.img_dialogx_demo_download;
-                                        case "收藏":
-                                            return R.mipmap.img_dialogx_demo_favorite;
-                                        case "赞!":
-                                            return R.mipmap.img_dialogx_demo_good;
-                                        case "不喜欢":
-                                            return R.mipmap.img_dialogx_demo_dislike;
-                                        case "所属专辑":
-                                            return R.mipmap.img_dialogx_demo_album;
-                                        case "复制链接":
-                                            return R.mipmap.img_dialogx_demo_link;
-                                        case "类似推荐":
-                                            return R.mipmap.img_dialogx_demo_recommend;
-                                    }
-                                    return 0;
-                                }
-                            })
-                            .setOnMenuItemClickListener(new OnMenuItemClickListener<BottomMenu>() {
-                                @Override
-                                public boolean onClick(BottomMenu dialog, CharSequence text, int index) {
-                                    PopTip.show(text);
-                                    return false;
-                                }
-                            });
+                    //因数据量大,尝试异步线程启动
+                    new Thread(){
+                        @Override
+                        public void run() {
+                            super.run();
+                            BottomMenu.show(new String[]{"添加", "查看", "编辑", "删除", "分享", "评论", "下载", "收藏", "赞!", "不喜欢", "所属专辑", "复制链接", "类似推荐", "添加", "查看", "编辑", "删除", "分享", "评论", "下载", "收藏", "赞!", "不喜欢", "所属专辑", "复制链接", "类似推荐"})
+                                    .setOnIconChangeCallBack(new OnIconChangeCallBack(true) {
+                                        @Override
+                                        public int getIcon(BottomMenu bottomMenu, int index, String menuText) {
+                                            switch (menuText) {
+                                                case "添加":
+                                                    return R.mipmap.img_dialogx_demo_add;
+                                                case "查看":
+                                                    return R.mipmap.img_dialogx_demo_view;
+                                                case "编辑":
+                                                    return R.mipmap.img_dialogx_demo_edit;
+                                                case "删除":
+                                                    return R.mipmap.img_dialogx_demo_delete;
+                                                case "分享":
+                                                    return R.mipmap.img_dialogx_demo_share;
+                                                case "评论":
+                                                    return R.mipmap.img_dialogx_demo_comment;
+                                                case "下载":
+                                                    return R.mipmap.img_dialogx_demo_download;
+                                                case "收藏":
+                                                    return R.mipmap.img_dialogx_demo_favorite;
+                                                case "赞!":
+                                                    return R.mipmap.img_dialogx_demo_good;
+                                                case "不喜欢":
+                                                    return R.mipmap.img_dialogx_demo_dislike;
+                                                case "所属专辑":
+                                                    return R.mipmap.img_dialogx_demo_album;
+                                                case "复制链接":
+                                                    return R.mipmap.img_dialogx_demo_link;
+                                                case "类似推荐":
+                                                    return R.mipmap.img_dialogx_demo_recommend;
+                                            }
+                                            return 0;
+                                        }
+                                    })
+                                    .setOnMenuItemClickListener(new OnMenuItemClickListener<BottomMenu>() {
+                                        @Override
+                                        public boolean onClick(BottomMenu dialog, CharSequence text, int index) {
+                                            PopTip.show(text);
+                                            return false;
+                                        }
+                                    });
+                        }
+                    }.start();
                 } else {
                     BottomMenu.show(new String[]{"新标签页中打开", "稍后阅读", "复制链接网址"})
                             .setMessage("http://www.kongzue.com/DialogX")

+ 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.41.beta3
+BUILD_VERSION=0.0.41.beta4
 BUILD_VERSION_INT=40