Sfoglia il codice sorgente

Added setMaxProgress() method to MaterialDialog.

Aidan Follestad 10 anni fa
parent
commit
d004454261

+ 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();