Kaynağa Gözat

Gradle building fixes.

Aidan Follestad 10 yıl önce
ebeveyn
işleme
18621672f3

+ 3 - 1
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -994,6 +994,8 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
          * By default, the multi choice callback is only called when the user clicks the positive button
          * or if there are no buttons. Call this to force it to always call on item clicks even if the
          * positive button exists.
+         *
+         * @return The Builder instance so you can chain calls to it.
          */
         public Builder alwaysCallMultiChoiceCallback() {
             this.alwaysCallMultiChoiceCallback = true;
@@ -1223,7 +1225,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
 
     /**
      * @deprecated Use getActionButton(com.afollestad.materialdialogs.DialogAction)} instead.
-     * <p/>
+     *
      * This will not return buttons that are actually in the layout itself, since the layout doesn't
      * contain buttons. This is only implemented to avoid crashing issues on Huawei devices. Huawei's
      * stock OS requires this method in order to detect visible buttons.

+ 61 - 183
library/src/main/java/com/afollestad/materialdialogs/MaterialDialogCompat.java

@@ -11,10 +11,7 @@ import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
 import android.support.annotation.StringRes;
 import android.view.View;
-import android.webkit.WebView;
-import android.widget.AdapterView;
 import android.widget.ListAdapter;
-import android.widget.ScrollView;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -37,90 +34,45 @@ public class MaterialDialogCompat {
 
         private DialogInterface.OnClickListener onClickListener;
 
-        /**
-         * Constructor using a context for this builder and the {@link MaterialDialog} it creates.
-         */
         public Builder(@NonNull Context context) {
             builder = new MaterialDialog.Builder(context);
         }
 
-        /**
-         * Set the message to display using the given resource id.
-         *
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setMessage(@StringRes int messageId) {
             builder.content(messageId);
             return this;
         }
 
-        /**
-         * Set the message to display.
-         *
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setMessage(@NonNull CharSequence message) {
             builder.content(message);
             return this;
         }
 
-        /**
-         * Set the title using the given resource id.
-         *
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setTitle(@StringRes int titleId) {
             builder.title(titleId);
             return this;
         }
 
-        /**
-         * Set the title displayed in the {@link MaterialDialog}.
-         *
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setTitle(@NonNull CharSequence title) {
             builder.title(title);
             return this;
         }
 
-        /**
-         * Set the resource id of the {@link android.graphics.drawable.Drawable} to be used in the title.
-         *
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setIcon(@DrawableRes int iconId) {
             builder.icon(iconId);
             return this;
         }
 
-        /**
-         * Set the {@link android.graphics.drawable.Drawable} to be used in the title.
-         *
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setIcon(Drawable icon) {
             builder.icon(icon);
             return this;
         }
 
-        /**
-         * Set the attribute ID of the {@link android.graphics.drawable.Drawable} to be used in the title (e.g. android.R.attr.dialogicon)
-         *
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setIconAttribute(@AttrRes int attrId) {
             builder.iconAttr(attrId);
             return this;
         }
 
-        /**
-         * Set a listener to be invoked when the negative button of the dialog is pressed.
-         *
-         * @param textId   The resource id of the text to display in the negative button
-         * @param listener The {@link DialogInterface.OnClickListener} to use.
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setNegativeButton(@StringRes int textId,
                                          DialogInterface.OnClickListener listener) {
             builder.negativeText(textId);
@@ -128,13 +80,6 @@ public class MaterialDialogCompat {
             return this;
         }
 
-        /**
-         * Set a listener to be invoked when the negative button of the dialog is pressed.
-         *
-         * @param text     The text to display in the negative button
-         * @param listener The {@link DialogInterface.OnClickListener} to use.
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setNegativeButton(CharSequence text,
                                          DialogInterface.OnClickListener listener) {
             builder.negativeText(text);
@@ -142,13 +87,6 @@ public class MaterialDialogCompat {
             return this;
         }
 
-        /**
-         * Set a listener to be invoked when the positive button of the dialog is pressed.
-         *
-         * @param textId   The resource id of the text to display in the positive button
-         * @param listener The {@link DialogInterface.OnClickListener} to use.
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setPositiveButton(@StringRes int textId,
                                          DialogInterface.OnClickListener listener) {
             builder.positiveText(textId);
@@ -156,13 +94,6 @@ public class MaterialDialogCompat {
             return this;
         }
 
-        /**
-         * Set a listener to be invoked when the positive button of the dialog is pressed.
-         *
-         * @param text     The text to display in the positive button
-         * @param listener The {@link DialogInterface.OnClickListener} to use.
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setPositiveButton(CharSequence text,
                                          DialogInterface.OnClickListener listener) {
             builder.positiveText(text);
@@ -170,13 +101,6 @@ public class MaterialDialogCompat {
             return this;
         }
 
-        /**
-         * Set a listener to be invoked when the neutral button of the dialog is pressed.
-         *
-         * @param textId   The resource id of the text to display in the neutral button
-         * @param listener The {@link DialogInterface.OnClickListener} to use.
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setNeutralButton(@StringRes int textId,
                                         DialogInterface.OnClickListener listener) {
             builder.neutralText(textId);
@@ -184,13 +108,6 @@ public class MaterialDialogCompat {
             return this;
         }
 
-        /**
-         * Set a listener to be invoked when the neutral button of the dialog is pressed.
-         *
-         * @param text     The text to display in the neutral button
-         * @param listener The {@link DialogInterface.OnClickListener} to use.
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setNeutralButton(CharSequence text,
                                         DialogInterface.OnClickListener listener) {
             builder.neutralText(text);
@@ -198,66 +115,34 @@ public class MaterialDialogCompat {
             return this;
         }
 
-        /**
-         * Sets whether the dialog is cancelable or not.  Default is true.
-         *
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setCancelable(boolean cancelable) {
             builder.cancelable(cancelable);
             return this;
         }
 
-        /**
-         * Set a list of items to be displayed in the dialog as the content, you will be notified of the
-         * selected item via the supplied listener. This should be an array type i.e. R.array.foo
-         *
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setItems(int itemsId, final DialogInterface.OnClickListener listener) {
             builder.items(itemsId);
             onClickListener = listener;
             return this;
         }
 
-        /**
-         * Set a list of items to be displayed in the dialog as the content, you will be notified of the
-         * selected item via the supplied listener.
-         *
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setItems(CharSequence[] items, DialogInterface.OnClickListener listener) {
             builder.items(items);
             onClickListener = listener;
             return this;
         }
 
-        /**
-         * Sets a custom {@link android.widget.ListAdapter} for the dialog's list
-         *
-         * @return This Builder object to allow for chaining of calls to set methods
-         */
         public Builder setAdapter(ListAdapter adapter) {
             builder.adapter = adapter;
             return this;
         }
 
-        /**
-         * Creates a {@link AlertDialog} with the arguments supplied to this builder. It does not
-         * {@link AlertDialog#show()} the dialog. This allows the user to do any extra processing
-         * before displaying the dialog. Use {@link #show()} if you don't have any other processing
-         * to do and want this to be created and displayed.
-         */
         public AlertDialog create() {
             addButtonsCallback();
             addItemsCallBack();
             return builder.build();
         }
 
-        /**
-         * Creates a {@link AlertDialog} with the arguments supplied to this builder and
-         * {@link AlertDialog#show()}'s the dialog.
-         */
         public AlertDialog show() {
             AlertDialog dialog = create();
             dialog.show();
@@ -302,24 +187,17 @@ public class MaterialDialogCompat {
             }
         }
 
-		/**
-		 * Set a custom view resource to be the contents of the Dialog.
-		 *
-		 * @param view	The view to use as the contents of the Dialog.
-		 * @return This
-		 */
-		public Builder setView(View view) {
-            boolean wrapInScrollView = !(view instanceof ScrollView || view instanceof AdapterView || view instanceof WebView);
-            builder.customView(view, wrapInScrollView);
-			return this;
-		}
+        public Builder setView(View view) {
+            builder.customView(view, false);
+            return this;
+        }
 
         /**
          * Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.
          *
-         * @param itemsId   A resource ID for the items (e.g. R.array.my_items)
-         * @param checkedItems	specifies which items are checked. It should be null in which case no items are checked. If non null it must be exactly the same length as the array of items.
-         * @param listener	notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog.		 * @return
+         * @param itemsId      A resource ID for the items (e.g. R.array.my_items)
+         * @param checkedItems specifies which items are checked. It should be null in which case no items are checked. If non null it must be exactly the same length as the array of items.
+         * @param listener     notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog.		 * @return
          * @return This
          */
         public Builder setMultiChoiceItems(@ArrayRes int itemsId, @Nullable final boolean[] checkedItems, final DialogInterface.OnMultiChoiceClickListener listener) {
@@ -328,23 +206,23 @@ public class MaterialDialogCompat {
             return this;
         }
 
-		/**
-		 * Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.
-		 *
-		 * @param items	the text of the items to be displayed in the list.
-		 * @param checkedItems	specifies which items are checked. It should be null in which case no items are checked. If non null it must be exactly the same length as the array of items.
-		 * @param listener	notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog.		 * @return
-		 * @return This
-		 */
-		public Builder setMultiChoiceItems(String[] items, @Nullable final boolean[] checkedItems, final DialogInterface.OnMultiChoiceClickListener listener) {
-			builder.items(items);
+        /**
+         * Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.
+         *
+         * @param items        the text of the items to be displayed in the list.
+         * @param checkedItems specifies which items are checked. It should be null in which case no items are checked. If non null it must be exactly the same length as the array of items.
+         * @param listener     notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog.		 * @return
+         * @return This
+         */
+        public Builder setMultiChoiceItems(String[] items, @Nullable final boolean[] checkedItems, final DialogInterface.OnMultiChoiceClickListener listener) {
+            builder.items(items);
             setUpMultiChoiceCallback(checkedItems, listener);
-			return this;
-		}
+            return this;
+        }
 
         private void setUpMultiChoiceCallback(@Nullable final boolean[] checkedItems, final DialogInterface.OnMultiChoiceClickListener listener) {
             Integer selectedIndicesArr[] = null;
-			/* Convert old style array of booleans-per-index to new list of indices */
+            /* Convert old style array of booleans-per-index to new list of indices */
             if (checkedItems != null) {
                 ArrayList<Integer> selectedIndices = new ArrayList<>();
                 for (int i = 0; i < checkedItems.length; i++) {
@@ -358,16 +236,16 @@ public class MaterialDialogCompat {
             builder.itemsCallbackMultiChoice(selectedIndicesArr, new MaterialDialog.ListCallbackMulti() {
                 @Override
                 public void onSelection(MaterialDialog dialog, Integer[] which, CharSequence[] text) {
-					/* which is a list of selected indices */
+                    /* which is a list of selected indices */
                     List<Integer> whichList = Arrays.asList(which);
                     if (checkedItems != null) {
-                        for(int i = 0; i < checkedItems.length; i++) {
+                        for (int i = 0; i < checkedItems.length; i++) {
                             /* save old state */
                             boolean oldChecked = checkedItems[i];
                             /* Record new state */
                             checkedItems[i] = whichList.contains(i);
                             /* Fire the listener if it changed */
-                            if(oldChecked != checkedItems[i]) {
+                            if (oldChecked != checkedItems[i]) {
                                 listener.onClick(dialog, i, checkedItems[i]);
                             }
                         }
@@ -376,43 +254,43 @@ public class MaterialDialogCompat {
             });
         }
 
-		/**
-		 * Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.
-		 *
-		 * @param items	the items to be displayed.
-		 * @param checkedItem	specifies which item is checked. If -1 no items are checked.
-		 * @param listener	notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog.
-		 * @return This
-		 */
-		public Builder setSingleChoiceItems(String[] items, int checkedItem, final DialogInterface.OnClickListener listener) {
-			builder.items(items);
-			builder.itemsCallbackSingleChoice(checkedItem, new MaterialDialog.ListCallback() {
-				@Override
-				public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
-					listener.onClick(dialog, which);
-				}
-			});
-			return this;
-		}
-
-		/**
-		 * Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.
-		 *
-		 * @param itemsId	the resource id of an array i.e. R.array.foo
-		 * @param checkedItem	specifies which item is checked. If -1 no items are checked.
-		 * @param listener	notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog.
-		 * @return This
-		 */
-		public Builder setSingleChoiceItems(@ArrayRes int itemsId, int checkedItem, final DialogInterface.OnClickListener listener) {
-			builder.items(itemsId);
-			builder.itemsCallbackSingleChoice(checkedItem, new MaterialDialog.ListCallback() {
-				@Override
-				public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
-					listener.onClick(dialog, which);
-				}
-			});
-			return this;
-		}
+        /**
+         * Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.
+         *
+         * @param items       the items to be displayed.
+         * @param checkedItem specifies which item is checked. If -1 no items are checked.
+         * @param listener    notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog.
+         * @return This
+         */
+        public Builder setSingleChoiceItems(String[] items, int checkedItem, final DialogInterface.OnClickListener listener) {
+            builder.items(items);
+            builder.itemsCallbackSingleChoice(checkedItem, new MaterialDialog.ListCallback() {
+                @Override
+                public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
+                    listener.onClick(dialog, which);
+                }
+            });
+            return this;
+        }
+
+        /**
+         * Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.
+         *
+         * @param itemsId     the resource id of an array i.e. R.array.foo
+         * @param checkedItem specifies which item is checked. If -1 no items are checked.
+         * @param listener    notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog.
+         * @return This
+         */
+        public Builder setSingleChoiceItems(@ArrayRes int itemsId, int checkedItem, final DialogInterface.OnClickListener listener) {
+            builder.items(itemsId);
+            builder.itemsCallbackSingleChoice(checkedItem, new MaterialDialog.ListCallback() {
+                @Override
+                public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
+                    listener.onClick(dialog, which);
+                }
+            });
+            return this;
+        }
 
         public Builder setOnCancelListener(DialogInterface.OnCancelListener listener) {
             builder.cancelListener(listener);
@@ -433,5 +311,5 @@ public class MaterialDialogCompat {
             builder.keyListener(listener);
             return this;
         }
-	}
+    }
 }