Browse Source

Merge pull request #1279 from smartjinyu/master

Allow list dialog items.size() = 0 rather than not initializing builder.items
Aidan Follestad 8 years ago
parent
commit
5f862626cf

+ 1 - 1
core/src/main/java/com/afollestad/materialdialogs/DialogInit.java

@@ -57,7 +57,7 @@ class DialogInit {
     static int getInflateLayout(MaterialDialog.Builder builder) {
         if (builder.customView != null) {
             return R.layout.md_dialog_custom;
-        } else if (builder.items != null && builder.items.size() > 0 || builder.adapter != null) {
+        } else if (builder.items != null || builder.adapter != null) {
             if (builder.checkBoxPrompt != null)
                 return R.layout.md_dialog_list_check;
             return R.layout.md_dialog_list;

+ 2 - 0
core/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -766,6 +766,8 @@ public class MaterialDialog extends DialogBase implements
                     i++;
                 }
                 items(array);
+            } else if (collection.size() == 0) {
+                items = new ArrayList<>();
             }
             return this;
         }