1
0
Эх сурвалжийг харах

0.0.50.beta37.pre
- CustomDialog 增加了 `setMaxWidth`、`setMaxHeight`、`setMinHeight`、`setMinWidth` 接口;
- 修复 FullScreenDialog 在特定情况下显示时会闪烁的问题;
- 易用性增强,BottomMenu 和 PopMenu 支持 setMenus(int...) 使用多个资源 id 来设置菜单文字,InputDialog 支持了仅设置标题和内容的静态显示方法;

Kongzue 2 долоо хоног өмнө
parent
commit
34b730205a

+ 19 - 4
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomMenu.java

@@ -753,6 +753,21 @@ public class BottomMenu extends BottomDialog {
         return this;
     }
 
+    public BottomMenu setMenus(int... menuListResId) {
+        this.menuList = Arrays.asList(getTextArray(menuListResId));
+        this.menuListAdapter = null;
+        preRefreshUI();
+        return this;
+    }
+
+    private String[] getTextArray(int[] menuListResId) {
+        String[] result = new String[menuListResId == null ? 0 : menuListResId.length];
+        for (int i = 0; i < (menuListResId == null ? 0 : menuListResId.length); i++) {
+            result[i] = getString(menuListResId[i]);
+        }
+        return result;
+    }
+
     public OnIconChangeCallBack<BottomMenu> getOnIconChangeCallBack() {
         return onIconChangeCallBack;
     }
@@ -1577,22 +1592,22 @@ public class BottomMenu extends BottomDialog {
         return this;
     }
 
-    public BottomMenu cleanAction(int actionId){
+    public BottomMenu cleanAction(int actionId) {
         dialogActionRunnableMap.remove(actionId);
         return this;
     }
 
-    public BottomMenu cleanAllAction(){
+    public BottomMenu cleanAllAction() {
         dialogActionRunnableMap.clear();
         return this;
     }
 
     // for BaseDialog use
-    protected void callDialogDismissPrivate(){
+    protected void callDialogDismissPrivate() {
         dismiss();
     }
 
-    public BottomMenu bindDismissWithLifecycleOwner(LifecycleOwner owner){
+    public BottomMenu bindDismissWithLifecycleOwner(LifecycleOwner owner) {
         super.bindDismissWithLifecycleOwnerPrivate(owner);
         return this;
     }

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

@@ -65,9 +65,9 @@ public class CustomDialog extends BaseDialog {
     protected DialogXAnimInterface<CustomDialog> dialogXAnimImpl;
 
     protected WeakReference<View> baseViewWeakReference;
-    protected int alignViewGravity = -1;                                    //指定菜单相对 baseView 的位置
-    protected int width = -1;                                               //指定菜单宽度
-    protected int height = -1;                                              //指定菜单高度
+    protected int alignViewGravity = -1;                                    //指定对话框相对 baseView 的位置
+    protected int width = -1;                                               //指定对话框宽度
+    protected int height = -1;                                              //指定对话框高度
     protected int[] baseViewLoc;
     protected int[] marginRelativeBaseView = new int[4];
 

+ 12 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/InputDialog.java

@@ -59,6 +59,12 @@ public class InputDialog extends MessageDialog {
         this.message = message;
         this.okText = okText;
     }
+
+    public InputDialog(CharSequence title, CharSequence message) {
+        cancelable = DialogX.cancelable;
+        this.title = title;
+        this.message = message;
+    }
     
     public InputDialog(int titleResId, int messageResId, int okTextResId) {
         cancelable = DialogX.cancelable;
@@ -66,6 +72,12 @@ public class InputDialog extends MessageDialog {
         this.message = getString(messageResId);
         this.okText = getString(okTextResId);
     }
+
+    public InputDialog(int titleResId, int messageResId) {
+        cancelable = DialogX.cancelable;
+        this.title = getString(titleResId);
+        this.message = getString(messageResId);
+    }
     
     public static InputDialog show(CharSequence title, CharSequence message, CharSequence okText) {
         InputDialog inputDialog = new InputDialog(title, message, okText);

+ 15 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopMenu.java

@@ -1060,6 +1060,21 @@ public class PopMenu extends BaseDialog {
         return this;
     }
 
+    public PopMenu setMenus(int... menuListResId) {
+        this.menuList = Arrays.asList(getTextArray(menuListResId));
+        this.menuListAdapter = null;
+        refreshUI();
+        return this;
+    }
+
+    private String[] getTextArray(int[] menuListResId) {
+        String[] result = new String[menuListResId == null ? 0 : menuListResId.length];
+        for (int i = 0; i < (menuListResId == null ? 0 : menuListResId.length); i++) {
+            result[i] = getString(menuListResId[i]);
+        }
+        return result;
+    }
+
     public void refreshUI() {
         if (getDialogImpl() == null) {
             return;