소스 검색

update 0.0.7 ver

kongzue 4 년 전
부모
커밋
b660fd14f7

+ 3 - 3
DialogX/build.gradle

@@ -6,7 +6,7 @@ def siteUrl = 'https://github.com/kongzue/DialogX' //项目在github主页地址
 def gitUrl = 'https://github.com/kongzue/DialogX.git'   //Git仓库的地址
 
 group = "com.kongzue.dialogx"
-version = "0.0.6"
+version = "0.0.7"
 
 android {
     compileSdkVersion 30
@@ -14,8 +14,8 @@ android {
     defaultConfig {
         minSdkVersion 21
         targetSdkVersion 30
-        versionCode 6
-        versionName "0.0.6"
+        versionCode 7
+        versionName "0.0.7"
 
         consumerProguardFiles "consumer-rules.pro"
 

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

@@ -16,6 +16,7 @@ import android.widget.ScrollView;
 import android.widget.TextView;
 
 import androidx.annotation.ColorInt;
+import androidx.annotation.ColorRes;
 
 import com.kongzue.dialogx.DialogX;
 import com.kongzue.dialogx.R;
@@ -81,35 +82,69 @@ public class BottomDialog extends BaseDialog {
         this.message = message;
     }
     
+    public BottomDialog(int titleResId, int messageResId) {
+        this.title = getString(titleResId);
+        this.message = getString(messageResId);
+    }
+    
     public static BottomDialog show(CharSequence title, CharSequence message) {
         BottomDialog bottomDialog = new BottomDialog(title, message);
         bottomDialog.show();
         return bottomDialog;
     }
     
+    public static BottomDialog show(int titleResId, int messageResId) {
+        BottomDialog bottomDialog = new BottomDialog(titleResId, messageResId);
+        bottomDialog.show();
+        return bottomDialog;
+    }
+    
     public BottomDialog(CharSequence title, CharSequence message, OnBindView<BottomDialog> onBindView) {
         this.title = title;
         this.message = message;
         this.onBindView = onBindView;
     }
     
+    public BottomDialog(int titleResId, int messageResId, OnBindView<BottomDialog> onBindView) {
+        this.title = getString(titleResId);
+        this.message = getString(messageResId);
+        this.onBindView = onBindView;
+    }
+    
     public static BottomDialog show(CharSequence title, CharSequence message, OnBindView<BottomDialog> onBindView) {
         BottomDialog bottomDialog = new BottomDialog(title, message, onBindView);
         bottomDialog.show();
         return bottomDialog;
     }
     
+    public static BottomDialog show(int titleResId, int messageResId, OnBindView<BottomDialog> onBindView) {
+        BottomDialog bottomDialog = new BottomDialog(titleResId, messageResId, onBindView);
+        bottomDialog.show();
+        return bottomDialog;
+    }
+    
     public BottomDialog(CharSequence title, OnBindView<BottomDialog> onBindView) {
         this.title = title;
         this.onBindView = onBindView;
     }
     
+    public BottomDialog(int titleResId, OnBindView<BottomDialog> onBindView) {
+        this.title = getString(titleResId);
+        this.onBindView = onBindView;
+    }
+    
     public static BottomDialog show(CharSequence title, OnBindView<BottomDialog> onBindView) {
         BottomDialog bottomDialog = new BottomDialog(title, onBindView);
         bottomDialog.show();
         return bottomDialog;
     }
     
+    public static BottomDialog show(int titleResId, OnBindView<BottomDialog> onBindView) {
+        BottomDialog bottomDialog = new BottomDialog(titleResId, onBindView);
+        bottomDialog.show();
+        return bottomDialog;
+    }
+    
     public BottomDialog(OnBindView<BottomDialog> onBindView) {
         this.onBindView = onBindView;
     }
@@ -403,7 +438,12 @@ public class BottomDialog extends BaseDialog {
     
     public void refreshUI() {
         if (dialogImpl == null) return;
-        dialogImpl.refreshView();
+        getRootFrameLayout().post(new Runnable() {
+            @Override
+            public void run() {
+                dialogImpl.refreshView();
+            }
+        });
     }
     
     public void dismiss() {
@@ -465,6 +505,12 @@ public class BottomDialog extends BaseDialog {
         return this;
     }
     
+    public BottomDialog setTitle(int titleResId) {
+        this.title = getString(titleResId);
+        refreshUI();
+        return this;
+    }
+    
     public CharSequence getMessage() {
         return message;
     }
@@ -475,6 +521,12 @@ public class BottomDialog extends BaseDialog {
         return this;
     }
     
+    public BottomDialog setMessage(int messageResId) {
+        this.message = getString(messageResId);
+        refreshUI();
+        return this;
+    }
+    
     public CharSequence getCancelButton() {
         return cancelText;
     }
@@ -485,6 +537,12 @@ public class BottomDialog extends BaseDialog {
         return this;
     }
     
+    public BottomDialog setCancelButton(int cancelTextResId) {
+        this.cancelText = getString(cancelTextResId);
+        refreshUI();
+        return this;
+    }
+    
     public BottomDialog setCancelButton(OnDialogButtonClickListener<BottomDialog> cancelButtonClickListener) {
         this.cancelButtonClickListener = cancelButtonClickListener;
         return this;
@@ -496,6 +554,12 @@ public class BottomDialog extends BaseDialog {
         return this;
     }
     
+    public BottomDialog setCancelButton(int cancelTextResId, OnDialogButtonClickListener<BottomDialog> cancelButtonClickListener) {
+        this.cancelText = getString(cancelTextResId);
+        this.cancelButtonClickListener = cancelButtonClickListener;
+        return this;
+    }
+    
     public BottomDialog setCustomView(OnBindView<BottomDialog> onBindView) {
         this.onBindView = onBindView;
         refreshUI();
@@ -576,4 +640,10 @@ public class BottomDialog extends BaseDialog {
         refreshUI();
         return this;
     }
+    
+    public BottomDialog setBackgroundColorRes(@ColorRes int backgroundRes) {
+        this.backgroundColor = getColor(backgroundRes);
+        refreshUI();
+        return this;
+    }
 }

+ 141 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomMenu.java

@@ -7,6 +7,7 @@ import android.widget.BaseAdapter;
 import android.widget.RelativeLayout;
 
 import androidx.annotation.ColorInt;
+import androidx.annotation.ColorRes;
 
 import com.kongzue.dialogx.DialogX;
 import com.kongzue.dialogx.R;
@@ -88,6 +89,114 @@ public class BottomMenu extends BottomDialog {
         return bottomMenu;
     }
     
+    public static BottomMenu show(CharSequence title, CharSequence message, List<CharSequence> menuList) {
+        BottomMenu bottomMenu = new BottomMenu();
+        bottomMenu.title = title;
+        bottomMenu.message = message;
+        bottomMenu.setMenuList(menuList);
+        bottomMenu.show();
+        return bottomMenu;
+    }
+    
+    public static BottomMenu showStringList(CharSequence title, CharSequence message, List<String> menuList) {
+        BottomMenu bottomMenu = new BottomMenu();
+        bottomMenu.title = title;
+        bottomMenu.message = message;
+        bottomMenu.setMenuStringList(menuList);
+        bottomMenu.show();
+        return bottomMenu;
+    }
+    
+    public static BottomMenu show(CharSequence title, CharSequence message, String[] menuList) {
+        BottomMenu bottomMenu = new BottomMenu();
+        bottomMenu.title = title;
+        bottomMenu.message = message;
+        bottomMenu.setMenuList(menuList);
+        bottomMenu.show();
+        return bottomMenu;
+    }
+    
+    public static BottomMenu show(CharSequence title, CharSequence message, CharSequence[] menuList) {
+        BottomMenu bottomMenu = new BottomMenu();
+        bottomMenu.title = title;
+        bottomMenu.message = message;
+        bottomMenu.setMenuList(menuList);
+        bottomMenu.show();
+        return bottomMenu;
+    }
+    
+    public static BottomMenu show(String title, String message, List<CharSequence> menuList) {
+        BottomMenu bottomMenu = new BottomMenu();
+        bottomMenu.title = title;
+        bottomMenu.message = message;
+        bottomMenu.setMenuList(menuList);
+        bottomMenu.show();
+        return bottomMenu;
+    }
+    
+    public static BottomMenu showStringList(String title, String message, List<String> menuList) {
+        BottomMenu bottomMenu = new BottomMenu();
+        bottomMenu.title = title;
+        bottomMenu.message = message;
+        bottomMenu.setMenuStringList(menuList);
+        bottomMenu.show();
+        return bottomMenu;
+    }
+    
+    public static BottomMenu show(String title, String message, String[] menuList) {
+        BottomMenu bottomMenu = new BottomMenu();
+        bottomMenu.title = title;
+        bottomMenu.message = message;
+        bottomMenu.setMenuList(menuList);
+        bottomMenu.show();
+        return bottomMenu;
+    }
+    
+    public static BottomMenu show(String title, String message, CharSequence[] menuList) {
+        BottomMenu bottomMenu = new BottomMenu();
+        bottomMenu.title = title;
+        bottomMenu.message = message;
+        bottomMenu.setMenuList(menuList);
+        bottomMenu.show();
+        return bottomMenu;
+    }
+    
+    public static BottomMenu show(int titleResId, int messageResId, List<CharSequence> menuList) {
+        BottomMenu bottomMenu = new BottomMenu();
+        bottomMenu.title = bottomMenu.getString(titleResId);
+        bottomMenu.message = bottomMenu.getString(messageResId);
+        bottomMenu.setMenuList(menuList);
+        bottomMenu.show();
+        return bottomMenu;
+    }
+    
+    public static BottomMenu showStringList(int titleResId, int messageResId, List<String> menuList) {
+        BottomMenu bottomMenu = new BottomMenu();
+        bottomMenu.title = bottomMenu.getString(titleResId);
+        bottomMenu.message = bottomMenu.getString(messageResId);
+        bottomMenu.setMenuStringList(menuList);
+        bottomMenu.show();
+        return bottomMenu;
+    }
+    
+    public static BottomMenu show(int titleResId, int messageResId, String[] menuList) {
+        BottomMenu bottomMenu = new BottomMenu();
+        bottomMenu.title = bottomMenu.getString(titleResId);
+        bottomMenu.message = bottomMenu.getString(messageResId);
+        bottomMenu.setMenuList(menuList);
+        bottomMenu.show();
+        return bottomMenu;
+    }
+    
+    public static BottomMenu show(int titleResId, int messageResId, CharSequence[] menuList) {
+        BottomMenu bottomMenu = new BottomMenu();
+        bottomMenu.title = bottomMenu.getString(titleResId);
+        bottomMenu.message = bottomMenu.getString(messageResId);
+        bottomMenu.setMenuList(menuList);
+        bottomMenu.show();
+        return bottomMenu;
+    }
+    
     @Override
     protected void onDialogInit(final DialogImpl dialog) {
         if (dialog != null) {
@@ -143,6 +252,7 @@ public class BottomMenu extends BottomDialog {
     @Override
     public void refreshUI() {
         super.refreshUI();
+        
         if (listView != null) {
             if (menuListAdapter == null) {
                 menuListAdapter = new NormalMenuArrayAdapter(me, getContext(), menuList);
@@ -247,6 +357,12 @@ public class BottomMenu extends BottomDialog {
         return this;
     }
     
+    public BottomMenu setTitle(int titleResId) {
+        this.title = getString(titleResId);
+        refreshUI();
+        return this;
+    }
+    
     public CharSequence getMessage() {
         return message;
     }
@@ -257,6 +373,12 @@ public class BottomMenu extends BottomDialog {
         return this;
     }
     
+    public BottomMenu setMessage(int messageResId) {
+        this.message = getString(messageResId);
+        refreshUI();
+        return this;
+    }
+    
     public CharSequence getCancelButton() {
         return cancelText;
     }
@@ -267,6 +389,12 @@ public class BottomMenu extends BottomDialog {
         return this;
     }
     
+    public BottomMenu setCancelButton(int cancelTextResId) {
+        this.cancelText = getString(cancelTextResId);
+        refreshUI();
+        return this;
+    }
+    
     public BottomMenu setCancelButton(OnDialogButtonClickListener cancelButtonClickListener) {
         this.cancelButtonClickListener = cancelButtonClickListener;
         return this;
@@ -279,6 +407,13 @@ public class BottomMenu extends BottomDialog {
         return this;
     }
     
+    public BottomMenu setCancelButton(int cancelTextResId, OnDialogButtonClickListener cancelButtonClickListener) {
+        this.cancelText = getString(cancelTextResId);
+        this.cancelButtonClickListener = cancelButtonClickListener;
+        refreshUI();
+        return this;
+    }
+    
     public BottomMenu setCustomView(OnBindView<BottomDialog> onBindView) {
         this.onBindView = onBindView;
         refreshUI();
@@ -392,4 +527,10 @@ public class BottomMenu extends BottomDialog {
         refreshUI();
         return this;
     }
+    
+    public BottomMenu setBackgroundColorRes(@ColorRes int backgroundRes) {
+        this.backgroundColor = getColor(backgroundRes);
+        refreshUI();
+        return this;
+    }
 }

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

@@ -217,7 +217,12 @@ public class CustomDialog extends BaseDialog {
     
     public void refreshUI() {
         if (dialogImpl == null) return;
-        dialogImpl.refreshView();
+        getRootFrameLayout().post(new Runnable() {
+            @Override
+            public void run() {
+                dialogImpl.refreshView();
+            }
+        });
     }
     
     public void dismiss() {

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

@@ -13,6 +13,7 @@ import android.widget.FrameLayout;
 import android.widget.RelativeLayout;
 
 import androidx.annotation.ColorInt;
+import androidx.annotation.ColorRes;
 
 import com.kongzue.dialogx.DialogX;
 import com.kongzue.dialogx.R;
@@ -233,7 +234,12 @@ public class FullScreenDialog extends BaseDialog {
     
     public void refreshUI() {
         if (dialogImpl == null) return;
-        dialogImpl.refreshView();
+        getRootFrameLayout().post(new Runnable() {
+            @Override
+            public void run() {
+                dialogImpl.refreshView();
+            }
+        });
     }
     
     public void dismiss() {
@@ -311,4 +317,10 @@ public class FullScreenDialog extends BaseDialog {
         refreshUI();
         return this;
     }
+    
+    public FullScreenDialog setBackgroundColorRes(@ColorRes int backgroundColorRes) {
+        this.backgroundColor = getColor(backgroundColorRes);
+        refreshUI();
+        return this;
+    }
 }

+ 126 - 2
DialogX/src/main/java/com/kongzue/dialogx/dialogs/InputDialog.java

@@ -3,6 +3,7 @@ package com.kongzue.dialogx.dialogs;
 import android.view.View;
 
 import androidx.annotation.ColorInt;
+import androidx.annotation.ColorRes;
 
 import com.kongzue.dialogx.interfaces.OnBackPressedListener;
 import com.kongzue.dialogx.interfaces.OnBindView;
@@ -34,12 +35,24 @@ public class InputDialog extends MessageDialog {
         this.okText = okText;
     }
     
+    public InputDialog(int titleResId, int messageResId, int okTextResId) {
+        this.title = getString(titleResId);
+        this.message = getString(messageResId);
+        this.okText = getString(okTextResId);
+    }
+    
     public static InputDialog show(CharSequence title, CharSequence message, CharSequence okText) {
         InputDialog inputDialog = new InputDialog(title, message, okText);
         inputDialog.show();
         return inputDialog;
     }
     
+    public static InputDialog show(int titleResId, int messageResId, int okTextResId) {
+        InputDialog inputDialog = new InputDialog(titleResId, messageResId, okTextResId);
+        inputDialog.show();
+        return inputDialog;
+    }
+    
     public InputDialog(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText) {
         this.title = title;
         this.message = message;
@@ -47,12 +60,25 @@ public class InputDialog extends MessageDialog {
         this.cancelText = cancelText;
     }
     
+    public InputDialog(int titleResId, int messageResId, int okTextResId, int cancelTextResId) {
+        this.title = getString(titleResId);
+        this.message = getString(messageResId);
+        this.okText = getString(okTextResId);
+        this.cancelText = getString(cancelTextResId);
+    }
+    
     public static InputDialog show(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText) {
         InputDialog inputDialog = new InputDialog(title, message, okText, cancelText);
         inputDialog.show();
         return inputDialog;
     }
     
+    public static InputDialog show(int titleResId, int messageResId, int okTextResId, int cancelTextResId) {
+        InputDialog inputDialog = new InputDialog(titleResId, messageResId, okTextResId, cancelTextResId);
+        inputDialog.show();
+        return inputDialog;
+    }
+    
     public InputDialog(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText, String inputText) {
         this.title = title;
         this.message = message;
@@ -75,12 +101,26 @@ public class InputDialog extends MessageDialog {
         this.otherText = otherText;
     }
     
+    public InputDialog(int titleResId, int messageResId, int okTextResId, int cancelTextResId, int otherTextResId) {
+        this.title = getString(titleResId);
+        this.message = getString(messageResId);
+        this.okText = getString(okTextResId);
+        this.cancelText = getString(cancelTextResId);
+        this.otherText = getString(otherTextResId);
+    }
+    
     public static InputDialog show(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText, CharSequence otherText) {
         InputDialog inputDialog = new InputDialog(title, message, okText, cancelText, otherText);
         inputDialog.show();
         return inputDialog;
     }
     
+    public static InputDialog show(int titleResId, int messageResId, int okTextResId, int cancelTextResId, int otherTextResId) {
+        InputDialog inputDialog = new InputDialog(titleResId, messageResId, okTextResId, cancelTextResId, otherTextResId);
+        inputDialog.show();
+        return inputDialog;
+    }
+    
     public InputDialog(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText, CharSequence otherText, String inputText) {
         this.title = title;
         this.message = message;
@@ -90,12 +130,27 @@ public class InputDialog extends MessageDialog {
         this.inputText = inputText;
     }
     
+    public InputDialog(int titleResId, int messageResId, int okTextResId, int cancelTextResId, int otherTextResId, int inputTextResId) {
+        this.title = getString(titleResId);
+        this.message = getString(messageResId);
+        this.okText = getString(okTextResId);
+        this.cancelText = getString(cancelTextResId);
+        this.otherText = getString(otherTextResId);
+        this.inputText = getString(inputTextResId);
+    }
+    
     public static InputDialog show(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText, CharSequence otherText, String inputText) {
         InputDialog inputDialog = new InputDialog(title, message, okText, cancelText, otherText, inputText);
         inputDialog.show();
         return inputDialog;
     }
     
+    public static InputDialog show(int titleResId, int messageResId, int okTextResId, int cancelTextResId, int otherTextResId, int inputTextResId)  {
+        InputDialog inputDialog = new InputDialog(titleResId, messageResId, okTextResId, cancelTextResId, otherTextResId, inputTextResId);
+        inputDialog.show();
+        return inputDialog;
+    }
+    
     public CharSequence getOkButton() {
         return okText;
     }
@@ -106,6 +161,12 @@ public class InputDialog extends MessageDialog {
         return this;
     }
     
+    public InputDialog setOkButton(int okTextResId) {
+        this.okText = getString(okTextResId);
+        refreshUI();
+        return this;
+    }
+    
     public InputDialog setOkButton(OnInputDialogButtonClickListener<InputDialog> okButtonClickListener) {
         this.okButtonClickListener = okButtonClickListener;
         return this;
@@ -118,6 +179,13 @@ public class InputDialog extends MessageDialog {
         return this;
     }
     
+    public InputDialog setOkButton(int okTextResId, OnInputDialogButtonClickListener<InputDialog> okButtonClickListener) {
+        this.okText = getString(okTextResId);
+        this.okButtonClickListener = okButtonClickListener;
+        refreshUI();
+        return this;
+    }
+    
     public CharSequence getCancelButton() {
         return cancelText;
     }
@@ -128,6 +196,12 @@ public class InputDialog extends MessageDialog {
         return this;
     }
     
+    public InputDialog setCancelButton(int cancelTextResId) {
+        this.cancelText = getString(cancelTextResId);
+        refreshUI();
+        return this;
+    }
+    
     public InputDialog setCancelButton(OnInputDialogButtonClickListener<InputDialog> cancelButtonClickListener) {
         this.cancelButtonClickListener = cancelButtonClickListener;
         return this;
@@ -140,6 +214,13 @@ public class InputDialog extends MessageDialog {
         return this;
     }
     
+    public InputDialog setCancelButton(int cancelTextResId, OnInputDialogButtonClickListener<InputDialog> cancelButtonClickListener) {
+        this.cancelText = getString(cancelTextResId);
+        this.cancelButtonClickListener = cancelButtonClickListener;
+        refreshUI();
+        return this;
+    }
+    
     public CharSequence getOtherButton() {
         return otherText;
     }
@@ -150,6 +231,12 @@ public class InputDialog extends MessageDialog {
         return this;
     }
     
+    public InputDialog setOtherButton(int otherTextResId) {
+        this.otherText = getString(otherTextResId);
+        refreshUI();
+        return this;
+    }
+    
     public InputDialog setOtherButton(OnInputDialogButtonClickListener<InputDialog> otherButtonClickListener) {
         this.otherButtonClickListener = otherButtonClickListener;
         return this;
@@ -162,6 +249,13 @@ public class InputDialog extends MessageDialog {
         return this;
     }
     
+    public InputDialog setOtherButton(int otherTextResId, OnInputDialogButtonClickListener<InputDialog> otherButtonClickListener) {
+        this.otherText = getString(otherTextResId);
+        this.otherButtonClickListener = otherButtonClickListener;
+        refreshUI();
+        return this;
+    }
+    
     public OnInputDialogButtonClickListener<InputDialog> getInputOkButtonClickListener() {
         return (OnInputDialogButtonClickListener<InputDialog>) okButtonClickListener;
     }
@@ -199,6 +293,12 @@ public class InputDialog extends MessageDialog {
         return this;
     }
     
+    public InputDialog setTitle(int titleResId) {
+        this.title = getString(titleResId);
+        refreshUI();
+        return this;
+    }
+    
     public CharSequence getMessage() {
         return message;
     }
@@ -209,6 +309,12 @@ public class InputDialog extends MessageDialog {
         return this;
     }
     
+    public InputDialog setMessage(int messageResId) {
+        this.message = getString(messageResId);
+        refreshUI();
+        return this;
+    }
+    
     public String getInputText() {
         return inputText;
     }
@@ -219,6 +325,12 @@ public class InputDialog extends MessageDialog {
         return this;
     }
     
+    public InputDialog setInputText(int inputTextResId) {
+        this.inputText = getString(inputTextResId);
+        refreshUI();
+        return this;
+    }
+    
     public String getInputHintText() {
         return inputHintText;
     }
@@ -229,6 +341,12 @@ public class InputDialog extends MessageDialog {
         return this;
     }
     
+    public InputDialog setInputHintText(int inputHintTextResId) {
+        this.inputHintText = getString(inputHintTextResId);
+        refreshUI();
+        return this;
+    }
+    
     public TextInfo getTitleTextInfo() {
         return titleTextInfo;
     }
@@ -326,7 +444,7 @@ public class InputDialog extends MessageDialog {
         return this;
     }
     
-    public InputDialog setCustomView(OnBindView<MessageDialog> onBindView){
+    public InputDialog setCustomView(OnBindView<MessageDialog> onBindView) {
         this.onBindView = onBindView;
         refreshUI();
         return this;
@@ -337,7 +455,7 @@ public class InputDialog extends MessageDialog {
         return onBindView.getCustomView();
     }
     
-    public InputDialog removeCustomView(){
+    public InputDialog removeCustomView() {
         this.onBindView.clean();
         refreshUI();
         return this;
@@ -352,4 +470,10 @@ public class InputDialog extends MessageDialog {
         refreshUI();
         return this;
     }
+    
+    public InputDialog setBackgroundColorRes(@ColorRes int backgroundColorResId) {
+        this.backgroundColor = getColor(backgroundColorResId);
+        refreshUI();
+        return this;
+    }
 }

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

@@ -18,6 +18,7 @@ import android.widget.Space;
 import android.widget.TextView;
 
 import androidx.annotation.ColorInt;
+import androidx.annotation.ColorRes;
 
 import com.kongzue.dialogx.DialogX;
 import com.kongzue.dialogx.R;
@@ -89,12 +90,24 @@ public class MessageDialog extends BaseDialog {
         this.okText = okText;
     }
     
+    public MessageDialog(int titleResId, int messageResId, int okTextResId) {
+        this.title = getString(titleResId);
+        this.message = getString(messageResId);
+        this.okText = getString(okTextResId);
+    }
+    
     public static MessageDialog show(CharSequence title, CharSequence message, CharSequence okText) {
         MessageDialog messageDialog = new MessageDialog(title, message, okText);
         messageDialog.show();
         return messageDialog;
     }
     
+    public static MessageDialog show(int titleResId, int messageResId, int okTextResId) {
+        MessageDialog messageDialog = new MessageDialog(titleResId, messageResId, okTextResId);
+        messageDialog.show();
+        return messageDialog;
+    }
+    
     public MessageDialog(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText) {
         this.title = title;
         this.message = message;
@@ -102,12 +115,25 @@ public class MessageDialog extends BaseDialog {
         this.cancelText = cancelText;
     }
     
+    public MessageDialog(int titleResId, int messageResId, int okTextResId, int cancelTextResId) {
+        this.title = getString(titleResId);
+        this.message = getString(messageResId);
+        this.okText = getString(okTextResId);
+        this.cancelText = getString(cancelTextResId);
+    }
+    
     public static MessageDialog show(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText) {
         MessageDialog messageDialog = new MessageDialog(title, message, okText, cancelText);
         messageDialog.show();
         return messageDialog;
     }
     
+    public static MessageDialog show(int titleResId, int messageResId, int okTextResId, int cancelTextResId) {
+        MessageDialog messageDialog = new MessageDialog(titleResId, messageResId, okTextResId, cancelTextResId);
+        messageDialog.show();
+        return messageDialog;
+    }
+    
     public MessageDialog(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText, CharSequence otherText) {
         this.title = title;
         this.message = message;
@@ -116,12 +142,26 @@ public class MessageDialog extends BaseDialog {
         this.otherText = otherText;
     }
     
+    public MessageDialog(int titleResId, int messageResId, int okTextResId, int cancelTextResId, int otherTextResId) {
+        this.title = getString(titleResId);
+        this.message = getString(messageResId);
+        this.okText = getString(okTextResId);
+        this.cancelText = getString(cancelTextResId);
+        this.otherText = getString(otherTextResId);
+    }
+    
     public static MessageDialog show(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText, CharSequence otherText) {
         MessageDialog messageDialog = new MessageDialog(title, message, okText, cancelText, otherText);
         messageDialog.show();
         return messageDialog;
     }
     
+    public static MessageDialog show(int titleResId, int messageResId, int okTextResId, int cancelTextResId, int otherTextResId) {
+        MessageDialog messageDialog = new MessageDialog(titleResId, messageResId, okTextResId, cancelTextResId, otherTextResId);
+        messageDialog.show();
+        return messageDialog;
+    }
+    
     protected DialogImpl dialogImpl;
     
     public void show() {
@@ -136,7 +176,12 @@ public class MessageDialog extends BaseDialog {
     
     public void refreshUI() {
         if (dialogImpl == null) return;
-        dialogImpl.refreshView();
+        getRootFrameLayout().post(new Runnable() {
+            @Override
+            public void run() {
+                dialogImpl.refreshView();
+            }
+        });
     }
     
     class DialogImpl implements DialogConvertViewInterface {
@@ -337,6 +382,7 @@ public class MessageDialog extends BaseDialog {
             showText(btnSelectNegative, cancelText);
             showText(btnSelectOther, otherText);
             txtInput.setText(inputText);
+            txtInput.setHint(inputHintText);
             if (spaceOtherButton != null) {
                 if (otherText == null) {
                     spaceOtherButton.setVisibility(View.GONE);
@@ -566,6 +612,12 @@ public class MessageDialog extends BaseDialog {
         return this;
     }
     
+    public MessageDialog setOkButton(int okTextRedId) {
+        this.okText = getString(okTextRedId);
+        refreshUI();
+        return this;
+    }
+    
     public MessageDialog setOkButton(OnDialogButtonClickListener<MessageDialog> okButtonClickListener) {
         this.okButtonClickListener = okButtonClickListener;
         return this;
@@ -578,6 +630,13 @@ public class MessageDialog extends BaseDialog {
         return this;
     }
     
+    public MessageDialog setOkButton(int okTextRedId, OnDialogButtonClickListener<MessageDialog> okButtonClickListener) {
+        this.okText = getString(okTextRedId);
+        this.okButtonClickListener = okButtonClickListener;
+        refreshUI();
+        return this;
+    }
+    
     public CharSequence getCancelButton() {
         return cancelText;
     }
@@ -588,6 +647,12 @@ public class MessageDialog extends BaseDialog {
         return this;
     }
     
+    public MessageDialog setCancelButton(int cancelTextResId) {
+        this.cancelText = getString(cancelTextResId);
+        refreshUI();
+        return this;
+    }
+    
     public MessageDialog setCancelButton(OnDialogButtonClickListener<MessageDialog> cancelButtonClickListener) {
         this.cancelButtonClickListener = cancelButtonClickListener;
         return this;
@@ -600,6 +665,13 @@ public class MessageDialog extends BaseDialog {
         return this;
     }
     
+    public MessageDialog setCancelButton(int cancelTextResId, OnDialogButtonClickListener<MessageDialog> cancelButtonClickListener) {
+        this.cancelText = getString(cancelTextResId);
+        this.cancelButtonClickListener = cancelButtonClickListener;
+        refreshUI();
+        return this;
+    }
+    
     public CharSequence getOtherButton() {
         return otherText;
     }
@@ -610,6 +682,12 @@ public class MessageDialog extends BaseDialog {
         return this;
     }
     
+    public MessageDialog setOtherButton(int otherTextResId) {
+        this.otherText = getString(otherTextResId);
+        refreshUI();
+        return this;
+    }
+    
     public MessageDialog setOtherButton(OnDialogButtonClickListener<MessageDialog> otherButtonClickListener) {
         this.otherButtonClickListener = otherButtonClickListener;
         return this;
@@ -622,6 +700,13 @@ public class MessageDialog extends BaseDialog {
         return this;
     }
     
+    public MessageDialog setOtherButton(int otherTextResId, OnDialogButtonClickListener<MessageDialog> otherButtonClickListener) {
+        this.otherText = getString(otherTextResId);
+        this.otherButtonClickListener = otherButtonClickListener;
+        refreshUI();
+        return this;
+    }
+    
     public OnDialogButtonClickListener<MessageDialog> getOkButtonClickListener() {
         return (OnDialogButtonClickListener<MessageDialog>) okButtonClickListener;
     }
@@ -659,6 +744,12 @@ public class MessageDialog extends BaseDialog {
         return this;
     }
     
+    public MessageDialog setTitle(int titleResId) {
+        this.title = getString(titleResId);
+        refreshUI();
+        return this;
+    }
+    
     public CharSequence getMessage() {
         return message;
     }
@@ -669,6 +760,12 @@ public class MessageDialog extends BaseDialog {
         return this;
     }
     
+    public MessageDialog setMessage(int messageResId) {
+        this.message = getString(messageResId);
+        refreshUI();
+        return this;
+    }
+    
     public TextInfo getTitleTextInfo() {
         return titleTextInfo;
     }
@@ -786,4 +883,10 @@ public class MessageDialog extends BaseDialog {
             return "";
         }
     }
+    
+    public MessageDialog setBackgroundColorRes(@ColorRes int backgroundColorResId) {
+        this.backgroundColor = getColor(backgroundColorResId);
+        refreshUI();
+        return this;
+    }
 }

+ 104 - 4
DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopTip.java

@@ -14,6 +14,7 @@ import android.widget.RelativeLayout;
 import android.widget.TextView;
 
 import androidx.annotation.ColorInt;
+import androidx.annotation.ColorRes;
 import androidx.annotation.IdRes;
 
 import com.kongzue.dialogx.DialogX;
@@ -84,6 +85,11 @@ public class PopTip extends BaseDialog {
         this.message = message;
     }
     
+    public PopTip(int messageResId) {
+        super();
+        this.message = getString(messageResId);
+    }
+    
     public PopTip(int iconResId, CharSequence message) {
         super();
         this.iconResId = iconResId;
@@ -97,18 +103,37 @@ public class PopTip extends BaseDialog {
         this.buttonText = buttonText;
     }
     
+    public PopTip(int iconResId, int messageResId, int buttonTextResId) {
+        super();
+        this.iconResId = iconResId;
+        this.message = getString(messageResId);
+        this.buttonText = getString(buttonTextResId);
+    }
+    
     public PopTip(CharSequence message, CharSequence buttonText) {
         super();
         this.message = message;
         this.buttonText = buttonText;
     }
     
+    public PopTip(int messageResId, int buttonTextResId) {
+        super();
+        this.message = getString(messageResId);
+        this.buttonText = getString(buttonTextResId);
+    }
+    
     public PopTip(CharSequence message, OnBindView<PopTip> onBindView) {
         super();
         this.message = message;
         this.onBindView = onBindView;
     }
     
+    public PopTip(int messageResId, OnBindView<PopTip> onBindView) {
+        super();
+        this.message = getString(messageResId);
+        this.onBindView = onBindView;
+    }
+    
     public PopTip(int iconResId, CharSequence message, OnBindView<PopTip> onBindView) {
         super();
         this.iconResId = iconResId;
@@ -124,6 +149,14 @@ public class PopTip extends BaseDialog {
         this.onBindView = onBindView;
     }
     
+    public PopTip(int iconResId, int messageResId, int buttonTextResId, OnBindView<PopTip> onBindView) {
+        super();
+        this.iconResId = iconResId;
+        this.message = getString(messageResId);
+        this.buttonText = getString(buttonTextResId);
+        this.onBindView = onBindView;
+    }
+    
     public PopTip(CharSequence message, CharSequence buttonText, OnBindView<PopTip> onBindView) {
         super();
         this.message = message;
@@ -131,6 +164,13 @@ public class PopTip extends BaseDialog {
         this.onBindView = onBindView;
     }
     
+    public PopTip(int messageResId, int buttonTextResId, OnBindView<PopTip> onBindView) {
+        super();
+        this.message = getString(messageResId);
+        this.buttonText = getString(buttonTextResId);
+        this.onBindView = onBindView;
+    }
+    
     public static PopTip show(OnBindView<PopTip> onBindView) {
         PopTip popTip = new PopTip(onBindView);
         popTip.show();
@@ -143,18 +183,36 @@ public class PopTip extends BaseDialog {
         return popTip;
     }
     
+    public static PopTip show(int messageResId) {
+        PopTip popTip = new PopTip(messageResId);
+        popTip.show();
+        return popTip;
+    }
+    
     public static PopTip show(CharSequence message, OnBindView<PopTip> onBindView) {
         PopTip popTip = new PopTip(message, onBindView);
         popTip.show();
         return popTip;
     }
     
+    public static PopTip show(int messageResId, OnBindView<PopTip> onBindView) {
+        PopTip popTip = new PopTip(messageResId, onBindView);
+        popTip.show();
+        return popTip;
+    }
+    
     public static PopTip show(CharSequence message, CharSequence buttonText) {
         PopTip popTip = new PopTip(message, buttonText);
         popTip.show();
         return popTip;
     }
     
+    public static PopTip show(int messageResId, int buttonTextResId) {
+        PopTip popTip = new PopTip(messageResId, buttonTextResId);
+        popTip.show();
+        return popTip;
+    }
+    
     public static PopTip show(int iconResId, CharSequence message, OnBindView<PopTip> onBindView) {
         PopTip popTip = new PopTip(iconResId, message, onBindView);
         popTip.show();
@@ -179,12 +237,24 @@ public class PopTip extends BaseDialog {
         return popTip;
     }
     
+    public static PopTip show(int iconResId, int messageResId, int buttonTextResId, OnBindView<PopTip> onBindView) {
+        PopTip popTip = new PopTip(iconResId, messageResId, buttonTextResId, onBindView);
+        popTip.show();
+        return popTip;
+    }
+    
     public static PopTip show(CharSequence message, CharSequence buttonText, OnBindView<PopTip> onBindView) {
         PopTip popTip = new PopTip(message, buttonText, onBindView);
         popTip.show();
         return popTip;
     }
     
+    public static PopTip show(int messageResId, int buttonTextResId, OnBindView<PopTip> onBindView) {
+        PopTip popTip = new PopTip(messageResId, buttonTextResId, onBindView);
+        popTip.show();
+        return popTip;
+    }
+    
     public void show() {
         super.beforeShow();
         if (DialogX.onlyOnePopTip) {
@@ -362,7 +432,7 @@ public class PopTip extends BaseDialog {
                     }
                     boxCustom.addView(onBindView.getCustomView(), lp);
                     boxCustom.setVisibility(View.VISIBLE);
-                }else{
+                } else {
                     boxCustom.setVisibility(View.GONE);
                 }
             }
@@ -389,12 +459,12 @@ public class PopTip extends BaseDialog {
                 boxBody.setOnClickListener(new View.OnClickListener() {
                     @Override
                     public void onClick(View v) {
-                        if (!onPopTipClickListener.onClick(me, v)){
+                        if (!onPopTipClickListener.onClick(me, v)) {
                             dismiss();
                         }
                     }
                 });
-            }else{
+            } else {
                 boxBody.setOnClickListener(null);
                 boxBody.setClickable(false);
             }
@@ -423,7 +493,12 @@ public class PopTip extends BaseDialog {
     
     public void refreshUI() {
         if (dialogImpl == null) return;
-        dialogImpl.refreshView();
+        getRootFrameLayout().post(new Runnable() {
+            @Override
+            public void run() {
+                dialogImpl.refreshView();
+            }
+        });
     }
     
     public void dismiss() {
@@ -501,6 +576,12 @@ public class PopTip extends BaseDialog {
         return this;
     }
     
+    public PopTip setMessage(int messageResId) {
+        this.message = getString(messageResId);
+        refreshUI();
+        return this;
+    }
+    
     public CharSequence getButtonText() {
         return buttonText;
     }
@@ -511,6 +592,12 @@ public class PopTip extends BaseDialog {
         return this;
     }
     
+    public PopTip setButton(int buttonTextResId) {
+        this.buttonText = getString(buttonTextResId);
+        refreshUI();
+        return this;
+    }
+    
     public PopTip setButton(CharSequence buttonText, OnDialogButtonClickListener<PopTip> onButtonClickListener) {
         this.buttonText = buttonText;
         this.onButtonClickListener = onButtonClickListener;
@@ -518,6 +605,13 @@ public class PopTip extends BaseDialog {
         return this;
     }
     
+    public PopTip setButton(int buttonTextResId, OnDialogButtonClickListener<PopTip> onButtonClickListener) {
+        this.buttonText = getString(buttonTextResId);
+        this.onButtonClickListener = onButtonClickListener;
+        refreshUI();
+        return this;
+    }
+    
     public PopTip setButton(OnDialogButtonClickListener<PopTip> onButtonClickListener) {
         this.onButtonClickListener = onButtonClickListener;
         return this;
@@ -581,4 +675,10 @@ public class PopTip extends BaseDialog {
         refreshUI();
         return this;
     }
+    
+    public PopTip setBackgroundColorRes(@ColorRes int backgroundColorResId) {
+        this.backgroundColor = getColor(backgroundColorResId);
+        refreshUI();
+        return this;
+    }
 }

+ 25 - 9
DialogX/src/main/java/com/kongzue/dialogx/dialogs/TipDialog.java

@@ -11,20 +11,24 @@ import java.lang.ref.WeakReference;
  */
 public class TipDialog extends WaitDialog {
     
-    public static TipDialog show(CharSequence message) {
-        TipDialog tipDialog = new TipDialog();
-        tipDialog.message = message;
-        tipDialog.show();
-        return tipDialog;
-    }
-    
     protected TipDialog() {
         super();
     }
     
+    public static WaitDialog show(int messageResId, TYPE tip) {
+        DialogImpl dialogImpl = me().dialogImpl;
+        me().preMessage(messageResId);
+        if (dialogImpl != null) {
+            dialogImpl.showTip(tip);
+        } else {
+            me().showTip(messageResId, tip);
+        }
+        return me();
+    }
+    
     public static WaitDialog show(CharSequence message, TYPE tip) {
         DialogImpl dialogImpl = me().dialogImpl;
-        me().message = message;
+        me().preMessage(message);
         if (dialogImpl != null) {
             dialogImpl.showTip(tip);
         } else {
@@ -33,9 +37,21 @@ public class TipDialog extends WaitDialog {
         return me();
     }
     
+    public static WaitDialog show(int messageResId, TYPE tip, long duration) {
+        DialogImpl dialogImpl = me().dialogImpl;
+        me().preMessage(messageResId);
+        me().tipShowDuration = duration;
+        if (dialogImpl != null) {
+            dialogImpl.showTip(tip);
+        } else {
+            me().showTip(messageResId, tip);
+        }
+        return me();
+    }
+    
     public static WaitDialog show(CharSequence message, TYPE tip, long duration) {
         DialogImpl dialogImpl = me().dialogImpl;
-        me().message = message;
+        me().preMessage(message);
         me().tipShowDuration = duration;
         if (dialogImpl != null) {
             dialogImpl.showTip(tip);

+ 89 - 5
DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java

@@ -12,6 +12,7 @@ import android.widget.RelativeLayout;
 import android.widget.TextView;
 
 import androidx.annotation.ColorInt;
+import androidx.annotation.ColorRes;
 
 import com.kongzue.dialogx.R;
 import com.kongzue.dialogx.impl.AnimatorListenerEndCallBack;
@@ -49,6 +50,7 @@ public class WaitDialog extends BaseDialog {
     protected CharSequence message;
     protected long tipShowDuration = 1500;
     protected float waitProgress = -1;
+    protected int showType = -1;        //-1:Waitdialog 状态标示符,其余为 TipDialog 状态标示
     
     private DialogLifecycleCallback<WaitDialog> dialogLifecycleCallback;
     
@@ -61,7 +63,9 @@ public class WaitDialog extends BaseDialog {
     public static WaitDialog show(CharSequence message) {
         DialogImpl dialogImpl = me().dialogImpl;
         me().message = message;
+        me().showType = -1;
         if (dialogImpl != null) {
+            dialogImpl.progressView.loading();
             setMessage(message);
             return me();
         } else {
@@ -72,16 +76,50 @@ public class WaitDialog extends BaseDialog {
         }
     }
     
+    public static WaitDialog show(int messageResId) {
+        DialogImpl dialogImpl = me().dialogImpl;
+        me().preMessage(messageResId);
+        me().showType = -1;
+        if (dialogImpl != null) {
+            dialogImpl.progressView.loading();
+            setMessage(messageResId);
+            return me();
+        } else {
+            WaitDialog waitDialog = new WaitDialog();
+            waitDialog.preMessage(messageResId);
+            waitDialog.show();
+            return waitDialog;
+        }
+    }
+    
     public static WaitDialog show(CharSequence message, float progress) {
         DialogImpl dialogImpl = me().dialogImpl;
-        me().message = message;
+        me().showType = -1;
+        me().preMessage(message);
         if (dialogImpl != null) {
             setMessage(message);
             me().setProgress(progress);
             return me();
         } else {
             WaitDialog waitDialog = new WaitDialog();
-            waitDialog.message = message;
+            waitDialog.preMessage(message);
+            waitDialog.show();
+            waitDialog.setProgress(progress);
+            return waitDialog;
+        }
+    }
+    
+    public static WaitDialog show(int messageResId, float progress) {
+        DialogImpl dialogImpl = me().dialogImpl;
+        me().showType = -1;
+        me().preMessage(messageResId);
+        if (dialogImpl != null) {
+            setMessage(messageResId);
+            me().setProgress(progress);
+            return me();
+        } else {
+            WaitDialog waitDialog = new WaitDialog();
+            waitDialog.preMessage(messageResId);
             waitDialog.show();
             waitDialog.setProgress(progress);
             return waitDialog;
@@ -90,6 +128,7 @@ public class WaitDialog extends BaseDialog {
     
     public static WaitDialog show(float progress) {
         DialogImpl dialogImpl = me().dialogImpl;
+        me().showType = -1;
         if (dialogImpl != null) {
             me().setProgress(progress);
             return me();
@@ -277,6 +316,7 @@ public class WaitDialog extends BaseDialog {
         }
         
         public void showTip(TYPE tip) {
+            showType = tip.ordinal();
             if (progressView == null) return;
             switch (tip) {
                 case NONE:
@@ -299,7 +339,9 @@ public class WaitDialog extends BaseDialog {
                     progressView.postDelayed(new Runnable() {
                         @Override
                         public void run() {
-                            doDismiss(null);
+                            if (showType>-1) {
+                                doDismiss(null);
+                            }
                         }
                     }, tipShowDuration);
                 }
@@ -309,7 +351,12 @@ public class WaitDialog extends BaseDialog {
     
     public void refreshUI() {
         if (dialogImpl == null) return;
-        dialogImpl.refreshView();
+        getRootFrameLayout().post(new Runnable() {
+            @Override
+            public void run() {
+                dialogImpl.refreshView();
+            }
+        });
     }
     
     public void doDismiss() {
@@ -329,21 +376,52 @@ public class WaitDialog extends BaseDialog {
     protected TYPE readyTipType;
     
     protected void showTip(CharSequence message, TYPE type) {
+        showType = type.ordinal();
         this.message = message;
         readyTipType = type;
         show();
     }
     
+    protected void showTip(int messageResId, TYPE type) {
+        showType = type.ordinal();
+        this.message = getString(messageResId);
+        readyTipType = type;
+        show();
+    }
+    
     public static CharSequence getMessage() {
         return me().message;
     }
     
     public static WaitDialog setMessage(CharSequence message) {
-        me().message = message;
+        me().preMessage(message);
+        me().refreshUI();
+        return me();
+    }
+    
+    public static WaitDialog setMessage(int messageResId) {
+        me().preMessage(messageResId);
         me().refreshUI();
         return me();
     }
     
+    /**
+     * 用于从 WaitDialog 到 TipDialog 的消息设置
+     * 此方法不会立即执行,而是等到动画衔接完成后由事件设置
+     *
+     * @param message   消息
+     * @return          me
+     */
+    protected WaitDialog preMessage(CharSequence message) {
+        me().message = message;
+        return me();
+    }
+    
+    protected WaitDialog preMessage(int messageResId) {
+        me().message = getString(messageResId);
+        return me();
+    }
+    
     public DialogLifecycleCallback<WaitDialog> getDialogLifecycleCallback() {
         return dialogLifecycleCallback == null ? new DialogLifecycleCallback<WaitDialog>() {
         } : dialogLifecycleCallback;
@@ -394,4 +472,10 @@ public class WaitDialog extends BaseDialog {
         refreshUI();
         return this;
     }
+    
+    public WaitDialog setBackgroundColorRes(@ColorRes int backgroundColorResId) {
+        this.backgroundColor = getColor(backgroundColorResId);
+        refreshUI();
+        return this;
+    }
 }

+ 19 - 0
DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java

@@ -4,6 +4,7 @@ import android.app.Activity;
 import android.content.Context;
 import android.content.res.ColorStateList;
 import android.content.res.Resources;
+import android.graphics.Color;
 import android.graphics.Typeface;
 import android.util.Log;
 import android.util.TypedValue;
@@ -14,6 +15,8 @@ import android.widget.FrameLayout;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
+import androidx.annotation.ColorRes;
+
 import com.kongzue.dialogx.DialogX;
 import com.kongzue.dialogx.impl.ActivityLifecycleImpl;
 import com.kongzue.dialogx.util.TextInfo;
@@ -197,4 +200,20 @@ public class BaseDialog {
             error("DialogX 未初始化。\n请检查是否在启动对话框前进行初始化操作,使用以下代码进行初始化:\nDialogX.init(context);\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
         }
     }
+    
+    protected String getString(int titleResId) {
+        if (getContext() == null) {
+            error("DialogX 未初始化。\n请检查是否在启动对话框前进行初始化操作,使用以下代码进行初始化:\nDialogX.init(context);\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
+            return null;
+        }
+        return getContext().getString(titleResId);
+    }
+    
+    protected int getColor(int backgroundRes) {
+        if (getContext() == null) {
+            error("DialogX 未初始化。\n请检查是否在启动对话框前进行初始化操作,使用以下代码进行初始化:\nDialogX.init(context);\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
+            return Color.BLACK;
+        }
+        return getContext().getResources().getColor(backgroundRes);
+    }
 }

+ 5 - 7
DialogX/src/main/java/com/kongzue/dialogx/util/views/ProgressView.java

@@ -383,6 +383,7 @@ public class ProgressView extends View {
     
     public void progress(float progress) {
         if (rotateAnimator != null) rotateAnimator.cancel();
+        if (followAnimator != null) followAnimator.cancel();
         if (status != STATUS_PROGRESSING) {
             currentRotateDegrees = 0;
         }
@@ -416,14 +417,11 @@ public class ProgressView extends View {
         line1Y = 0;
         line2X = 0;
         line2Y = 0;
-        if (rotateAnimator != null) rotateAnimator.cancel();
-        rotateAnimator = ValueAnimator.ofFloat(0, 365);
-        rotateAnimator.setDuration(1000);
-        rotateAnimator.setInterpolator(new LinearInterpolator());
-        rotateAnimator.setRepeatCount(-1);
-        rotateAnimator.setInterpolator(new LinearInterpolator());
         status = STATUS_LOADING;
-        rotateAnimator.start();
+        if (rotateAnimator != null) rotateAnimator.cancel();
+        if (followAnimator != null) followAnimator.cancel();
+        isInited = false;
+        init(null);
     }
     
     public int getStatus() {

+ 16 - 7
README.md

@@ -15,11 +15,20 @@
 
 # DialogX优势
 
-- DialogX 采用全新的实现方式,**不**依赖 AlertDialog、Window 或 Fragment 实现,更加轻便快捷。
-- DialogX 的启动无需 context 参数,默认提供静态方法一句代码实现对话框的启动,使用更加方便。
-- DialogX 采用分离设计,默认自带 Material 主题,可选引入 IOS、Kongzue 等其他风格主题,大大减小 App 体积,同时提供了主题接口,如有定制需求完全可以自行实现一套私有主题。
-- 更低的耦合度,更少的问题,例如 DialogX 可以在对话框正在运行的过程中随意关闭 Activity ,而无需担心引发 WindowLeaked 错误。
-- 更流畅的体验,DialogX 的动画效果更加丰富,对话框启动动画采用非线性动画实现,更自带连贯的等待提示到完成错误动画过渡效果,让你的 APP 更具动感。
+对话框是一个软件对用户操作进行响应、反馈的重要组件,而 DialogX 将可以协助开发者快速完成这些事务。
+
+我们力求减少开发者所需要担心的,所需要顾虑的,而打造一款可以在任意时间,任意情况都能轻松使用的对话框组件。
+
+在轻松使用的前提下,DialogX 提供了更多的个性接口方便开发者进行扩展,包括在对话框内插入自定义布局,亮暗色模式的切换,甚至自定义更符合 App UI 的自定义主题。
+
+### DialogX的特性:
+
+- DialogX 采用全新的实现方式,**不依赖** AlertDialog、Window 或 Fragment 实现,更加轻便快捷。
+- DialogX 的启动与线程无关,你可以**在任意线程**启动 DialogX 而它都将自动在 UI 线程运行。
+- DialogX 的启动**无需 context 参数**,默认提供静态方法一句代码实现对话框的启动,使用更加方便。
+- DialogX 采用**主题分离设计**,默认自带 Material 主题,可选引入 IOS、Kongzue 等其他风格主题,大大减小 App 体积,同时提供了主题接口,如有定制需求完全可以自行实现一套私有主题。
+- 更低的耦合度,更少的问题,DialogX 可以在对话框正在**运行的过程中随意关闭 Activity** ,而无需担心以往 AlertDialog 等组件会引发的 WindowLeaked 错误。
+- 更流畅的体验,DialogX 的动画效果更加丰富,对话框启动动画采用**非线性动画**实现,更自带连贯的等待提示到完成错误动画过渡效果,让你的 APP 更具动感。
 - 所有主题默认支持亮暗色两种模式,只需一键配置即可实现亮暗色的对话框主题切换,更有自由的布局内容满足定制化需求。
 - 轻松的实现对话框的生命周期管控以及沉浸式适配。
 
@@ -96,7 +105,7 @@ DialogX 采用了主体分离结构,主框架仅包含 Material 设计风格
 想要在您的项目引入 DialogX,您需要在 app 的 build.gradle 文件中找到 `dependencies{}` 代码块,并在其中加入以下语句:
 
 ```
-implementation 'com.kongzue.dialogx:DialogX:0.0.6'
+implementation 'com.kongzue.dialogx:DialogX:0.0.7'
 ```
 
 若有需要,也可以手动配置 Maven:
@@ -105,7 +114,7 @@ implementation 'com.kongzue.dialogx:DialogX:0.0.6'
 <dependency>
   <groupId>com.kongzue.dialogx</groupId>
   <artifactId>DialogX</artifactId>
-  <version>0.0.6</version>
+  <version>0.0.7</version>
   <type>pom</type>
 </dependency>
 ```