Ver código fonte

Cleanup, updates, etc.

Aidan Follestad 10 anos atrás
pai
commit
5f382735c0

+ 5 - 18
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -610,7 +610,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
         final int childHeight = view.findViewById(R.id.content).getMeasuredHeight();
         return scrollView.getMeasuredHeight() < childHeight;
     }
-    
+
     /**
      * Measures the action button's and their text to decide whether or not the button should be stacked.
      */
@@ -622,31 +622,18 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
             invalidateActions();
             return;
         }
-
         isStacked = false;
         int buttonsWidth = 0;
-
-        if (mBuilder.positiveText != null) {
+        if (mBuilder.positiveText != null)
             buttonsWidth += positiveButton.getWidth();
-        }
-
-        if (mBuilder.neutralText != null) {
+        if (mBuilder.neutralText != null)
             buttonsWidth += neutralButton.getWidth();
-        }
-
-        if (mBuilder.negativeText != null) {
+        if (mBuilder.negativeText != null)
             buttonsWidth += negativeButton.getWidth();
-        }
-
         final int dialogWidth = getWindow().getDecorView().getMeasuredWidth();
         final int margins = (int) getContext().getResources().getDimension(R.dimen.md_button_padding_frame_side);
-
         final int effectiveDialogWidth = dialogWidth - 2 * margins;
-
-        if (buttonsWidth>effectiveDialogWidth) {
-            isStacked = true;
-        }
-
+        isStacked = buttonsWidth > effectiveDialogWidth;
         invalidateActions();
     }
 

+ 2 - 0
sample/src/main/java/com/afollestad/materialdialogssample/MainActivity.java

@@ -25,6 +25,7 @@ import com.afollestad.materialdialogs.DialogAction;
 import com.afollestad.materialdialogs.GravityEnum;
 import com.afollestad.materialdialogs.MaterialDialog;
 import com.afollestad.materialdialogs.Theme;
+import com.afollestad.materialdialogs.ThemeSingleton;
 
 import java.io.File;
 
@@ -418,6 +419,7 @@ public class MainActivity extends ActionBarActivity implements FolderSelectorDia
             public void onColorSelection(int index, int color, int darker) {
                 selectedColorIndex = index;
                 getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
+                ThemeSingleton.get().accentColor = color;
                 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                     getWindow().setStatusBarColor(darker);
             }