Explorar el Código

Merge pull request #931 from TheFinestArtist/setCanceledOnTouchOutside

Add setCanceledOnTouchOutside(boolean) method
Aidan Follestad hace 9 años
padre
commit
ffe972a075

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

@@ -74,7 +74,7 @@ class DialogInit {
 
         // Set cancelable flag and dialog background color
         dialog.setCancelable(builder.cancelable);
-        dialog.setCanceledOnTouchOutside(builder.cancelable);
+        dialog.setCanceledOnTouchOutside(builder.canceledOnTouchOutside);
         if (builder.backgroundColor == 0)
             builder.backgroundColor = DialogUtils.resolveColor(builder.context, R.attr.md_background_color);
         if (builder.backgroundColor != 0) {

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

@@ -404,6 +404,7 @@ public class MaterialDialog extends DialogBase implements
         protected boolean alwaysCallSingleChoiceCallback = false;
         protected Theme theme = Theme.LIGHT;
         protected boolean cancelable = true;
+        protected boolean canceledOnTouchOutside = true;
         protected float contentLineSpacingMultiplier = 1.2f;
         protected int selectedIndex = -1;
         protected Integer[] selectedIndices = null;
@@ -1162,6 +1163,11 @@ public class MaterialDialog extends DialogBase implements
             return this;
         }
 
+        public Builder canceledOnTouchOutside(boolean canceledOnTouchOutside) {
+            this.canceledOnTouchOutside = canceledOnTouchOutside;
+            return this;
+        }
+
         /**
          * This defaults to true. If set to false, the dialog will not automatically be dismissed
          * when an action button is pressed, and not automatically dismissed when the user selects