kongzue 3 years ago
parent
commit
f035aaf2f3

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

@@ -33,7 +33,7 @@ public class DialogX {
     //TipDialog 和 WaitDialog 明暗风格,不设置则默认根据 globalTheme 定义
     public static DialogX.THEME tipTheme;
     
-    //DialogX 实现模式
+    //DialogX 实现模式(实验性功能)
     public static IMPL_MODE implIMPLMode = IMPL_MODE.VIEW;
     
     //对话框最大宽度(像素)

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

@@ -290,9 +290,11 @@ public class BottomDialog extends BaseDialog {
             boxRoot.setOnLifecycleCallBack(new DialogXBaseRelativeLayout.OnLifecycleCallBack() {
                 @Override
                 public void onShow() {
+                    bkg.setY(getRootFrameLayout().getMeasuredHeight());
+                    
                     isShow = true;
                     boxRoot.setAlpha(0f);
-                    
+    
                     boxContent.getViewTreeObserver().addOnGlobalLayoutListener(onContentViewLayoutChangeListener);
                     
                     getDialogLifecycleCallback().onShow(me);
@@ -424,16 +426,6 @@ public class BottomDialog extends BaseDialog {
                             .alpha(1f)
                             .setInterpolator(new DecelerateInterpolator())
                             .setListener(null);
-    
-                    bkg.postDelayed(new Runnable() {
-                        @Override
-                        public void run() {
-                            isEnterAnimFinished = true;
-    
-                            bkg.setFocusable(true);
-                            bkg.requestFocus();
-                        }
-                    },enterAnimDurationTemp);
                 }
             });
         }
@@ -443,6 +435,7 @@ public class BottomDialog extends BaseDialog {
         private ViewTreeObserver.OnGlobalLayoutListener onContentViewLayoutChangeListener = new ViewTreeObserver.OnGlobalLayoutListener() {
             @Override
             public void onGlobalLayout() {
+                log("A");
                 if (boxContent != null) {
                     if (style.overrideBottomDialogRes() != null &&style.overrideBottomDialogRes().touchSlide()) {
                         //若内容布已经超出屏幕可用范围,且预设的对话框最大高度已知
@@ -491,6 +484,7 @@ public class BottomDialog extends BaseDialog {
                         bkgEnterAimY = boxBkg.getHeight() - bkg.getHeight();
                     }
                 }
+                isEnterAnimFinished = true;
             }
         };
         

+ 52 - 48
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomMenu.java

@@ -599,26 +599,30 @@ public class BottomMenu extends BottomDialog {
     
     @Override
     public void refreshUI() {
+        if (listView != null) {
+            if (menuListAdapter == null) {
+                menuListAdapter = new NormalMenuArrayAdapter(me, getContext(), menuList);
+            }
+            if (listView.getAdapter() == null) {
+                listView.setAdapter(menuListAdapter);
+            } else {
+                if (listView.getAdapter() != menuListAdapter) {
+                    listView.setAdapter(menuListAdapter);
+                } else {
+                    menuListAdapter.notifyDataSetChanged();
+                }
+            }
+        }
+        super.refreshUI();
+    }
+    
+    public void preRefreshUI(){
         runOnMain(new Runnable() {
             @Override
             public void run() {
-                if (listView != null) {
-                    if (menuListAdapter == null) {
-                        menuListAdapter = new NormalMenuArrayAdapter(me, getContext(), menuList);
-                    }
-                    if (listView.getAdapter() == null) {
-                        listView.setAdapter(menuListAdapter);
-                    } else {
-                        if (listView.getAdapter() != menuListAdapter) {
-                            listView.setAdapter(menuListAdapter);
-                        } else {
-                            menuListAdapter.notifyDataSetChanged();
-                        }
-                    }
-                }
+                refreshUI();
             }
         });
-        super.refreshUI();
     }
     
     @Override
@@ -633,7 +637,7 @@ public class BottomMenu extends BottomDialog {
     public BottomMenu setMenuList(List<CharSequence> menuList) {
         this.menuList = menuList;
         this.menuListAdapter = null;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -648,7 +652,7 @@ public class BottomMenu extends BottomDialog {
         this.menuList = new ArrayList<>();
         this.menuList.addAll(menuList);
         this.menuListAdapter = null;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -656,14 +660,14 @@ public class BottomMenu extends BottomDialog {
         this.menuList = new ArrayList<>();
         this.menuList.addAll(Arrays.asList(menuList));
         this.menuListAdapter = null;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
     public BottomMenu setMenuList(CharSequence[] menuList) {
         this.menuList = Arrays.asList(menuList);
         this.menuListAdapter = null;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -682,7 +686,7 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu setOnBackPressedListener(OnBackPressedListener onBackPressedListener) {
         this.onBackPressedListener = onBackPressedListener;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -714,7 +718,7 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu setCancelable(boolean cancelable) {
         this.privateCancelable = cancelable ? BOOLEAN.TRUE : BOOLEAN.FALSE;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -728,13 +732,13 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu setTitle(CharSequence title) {
         this.title = title;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
     public BottomMenu setTitle(int titleResId) {
         this.title = getString(titleResId);
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -744,13 +748,13 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu setMessage(CharSequence message) {
         this.message = message;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
     public BottomMenu setMessage(int messageResId) {
         this.message = getString(messageResId);
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -760,13 +764,13 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu setCancelButton(CharSequence cancelText) {
         this.cancelText = cancelText;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
     public BottomMenu setCancelButton(int cancelTextResId) {
         this.cancelText = getString(cancelTextResId);
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -778,20 +782,20 @@ public class BottomMenu extends BottomDialog {
     public BottomMenu setCancelButton(CharSequence cancelText, OnDialogButtonClickListener cancelButtonClickListener) {
         this.cancelText = cancelText;
         this.cancelButtonClickListener = cancelButtonClickListener;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
     public BottomMenu setCancelButton(int cancelTextResId, OnDialogButtonClickListener cancelButtonClickListener) {
         this.cancelText = getString(cancelTextResId);
         this.cancelButtonClickListener = cancelButtonClickListener;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
     public BottomMenu setCustomView(OnBindView<BottomDialog> onBindView) {
         this.onBindView = onBindView;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -802,7 +806,7 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu removeCustomView() {
         this.onBindView.clean();
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -812,7 +816,7 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu setAllowInterceptTouch(boolean allowInterceptTouch) {
         this.allowInterceptTouch = allowInterceptTouch;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -858,7 +862,7 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu setTitleTextInfo(TextInfo titleTextInfo) {
         this.titleTextInfo = titleTextInfo;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -868,7 +872,7 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu setMessageTextInfo(TextInfo messageTextInfo) {
         this.messageTextInfo = messageTextInfo;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -878,7 +882,7 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu setCancelTextInfo(TextInfo cancelTextInfo) {
         this.cancelTextInfo = cancelTextInfo;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -888,7 +892,7 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu setBackgroundColor(@ColorInt int backgroundColor) {
         this.backgroundColor = backgroundColor;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -905,7 +909,7 @@ public class BottomMenu extends BottomDialog {
         this.selectionIndex = selectionIndex;
         this.selectionItems = null;
         menuListAdapter = null;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -914,7 +918,7 @@ public class BottomMenu extends BottomDialog {
         this.selectionIndex = -1;
         this.selectionItems = null;
         menuListAdapter = null;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -928,7 +932,7 @@ public class BottomMenu extends BottomDialog {
             }
         }
         menuListAdapter = null;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -937,7 +941,7 @@ public class BottomMenu extends BottomDialog {
         this.selectionIndex = -1;
         this.selectionItems = new ArrayList<>();
         menuListAdapter = null;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -946,7 +950,7 @@ public class BottomMenu extends BottomDialog {
         this.selectionIndex = -1;
         this.selectionItems = new ArrayList<>(selectionItems);
         menuListAdapter = null;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -955,13 +959,13 @@ public class BottomMenu extends BottomDialog {
         this.selectionIndex = -1;
         this.selectionItems = null;
         menuListAdapter = null;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
     public BottomMenu setBackgroundColorRes(@ColorRes int backgroundRes) {
         this.backgroundColor = getColor(backgroundRes);
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -971,13 +975,13 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu setOkButton(CharSequence okText) {
         this.okText = okText;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
     public BottomMenu setOkButton(int OkTextResId) {
         this.okText = getString(OkTextResId);
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -1004,13 +1008,13 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu setOtherButton(CharSequence otherText) {
         this.otherText = otherText;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
     public BottomMenu setOtherButton(int OtherTextResId) {
         this.otherText = getString(OtherTextResId);
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     
@@ -1033,7 +1037,7 @@ public class BottomMenu extends BottomDialog {
     
     public BottomMenu setMaskColor(@ColorInt int maskColor) {
         this.maskColor = maskColor;
-        refreshUI();
+        preRefreshUI();
         return this;
     }
     

+ 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.WINDOW;
+        DialogX.implIMPLMode= DialogX.IMPL_MODE.VIEW;
         DialogX.globalStyle = new MaterialStyle() {
             @Override
             public PopTipSettings popTipSettings() {

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

@@ -461,7 +461,7 @@ public class MainActivity extends BaseActivity {
                                 @Override
                                 public boolean onClick(BottomMenu dialog, CharSequence text, int index) {
                                     PopTip.show(text);
-                                    return true;
+                                    return false;
                                 }
                             });
                 } else {
@@ -644,7 +644,6 @@ public class MainActivity extends BaseActivity {
                         });
                     }
                 })
-                        .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.38.beta7
+BUILD_VERSION=0.0.38
 BUILD_VERSION_INT=38