浏览代码

Added setMaxProgress() method to MaterialDialog.

Aidan Follestad 10 年之前
父节点
当前提交
d004454261
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

+ 8 - 0
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -1729,6 +1729,14 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
         mProgressLabel.setText(percentage + "%");
     }
 
+    public final void setMaxProgress(int max) {
+        if (Looper.myLooper() != Looper.getMainLooper())
+            throw new IllegalStateException("You can only set the dialog's progress from the UI thread.");
+        else if (mBuilder.mProgress <= -2)
+            throw new IllegalStateException("Cannot use setMaxProgress() on this dialog.");
+        mProgress.setMax(max);
+    }
+
     public final int getMaxProgress() {
         if (mProgress == null) return -1;
         return mProgress.getMax();