1
0
Aidan Follestad 7 жил өмнө
parent
commit
94f043dd35

+ 10 - 10
commons/src/main/java/com/afollestad/materialdialogs/color/ColorChooserDialog.java

@@ -397,21 +397,21 @@ public class ColorChooserDialog extends DialogFragment
 
     final MaterialDialog dialog = bd.build();
     final View v = dialog.getCustomView();
-    grid = (GridView) v.findViewById(R.id.md_grid);
+    grid = v.findViewById(R.id.md_grid);
 
     if (builder.allowUserCustom) {
       selectedCustomColor = preselectColor;
       colorChooserCustomFrame = v.findViewById(R.id.md_colorChooserCustomFrame);
-      customColorHex = (EditText) v.findViewById(R.id.md_hexInput);
+      customColorHex = v.findViewById(R.id.md_hexInput);
       customColorIndicator = v.findViewById(R.id.md_colorIndicator);
-      customSeekA = (SeekBar) v.findViewById(R.id.md_colorA);
-      customSeekAValue = (TextView) v.findViewById(R.id.md_colorAValue);
-      customSeekR = (SeekBar) v.findViewById(R.id.md_colorR);
-      customSeekRValue = (TextView) v.findViewById(R.id.md_colorRValue);
-      customSeekG = (SeekBar) v.findViewById(R.id.md_colorG);
-      customSeekGValue = (TextView) v.findViewById(R.id.md_colorGValue);
-      customSeekB = (SeekBar) v.findViewById(R.id.md_colorB);
-      customSeekBValue = (TextView) v.findViewById(R.id.md_colorBValue);
+      customSeekA = v.findViewById(R.id.md_colorA);
+      customSeekAValue = v.findViewById(R.id.md_colorAValue);
+      customSeekR = v.findViewById(R.id.md_colorR);
+      customSeekRValue = v.findViewById(R.id.md_colorRValue);
+      customSeekG = v.findViewById(R.id.md_colorG);
+      customSeekGValue = v.findViewById(R.id.md_colorGValue);
+      customSeekB = v.findViewById(R.id.md_colorB);
+      customSeekBValue = v.findViewById(R.id.md_colorBValue);
 
       if (!builder.allowUserCustomAlpha) {
         v.findViewById(R.id.md_colorALabel).setVisibility(View.GONE);

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

@@ -143,17 +143,17 @@ class DialogInit {
     }
 
     // Retrieve references to views
-    dialog.title = (TextView) dialog.view.findViewById(R.id.md_title);
-    dialog.icon = (ImageView) dialog.view.findViewById(R.id.md_icon);
+    dialog.title = dialog.view.findViewById(R.id.md_title);
+    dialog.icon = dialog.view.findViewById(R.id.md_icon);
     dialog.titleFrame = dialog.view.findViewById(R.id.md_titleFrame);
-    dialog.content = (TextView) dialog.view.findViewById(R.id.md_content);
-    dialog.recyclerView = (RecyclerView) dialog.view.findViewById(R.id.md_contentRecyclerView);
-    dialog.checkBoxPrompt = (CheckBox) dialog.view.findViewById(R.id.md_promptCheckbox);
+    dialog.content = dialog.view.findViewById(R.id.md_content);
+    dialog.recyclerView = dialog.view.findViewById(R.id.md_contentRecyclerView);
+    dialog.checkBoxPrompt = dialog.view.findViewById(R.id.md_promptCheckbox);
 
     // Button views initially used by checkIfStackingNeeded()
-    dialog.positiveButton = (MDButton) dialog.view.findViewById(R.id.md_buttonDefaultPositive);
-    dialog.neutralButton = (MDButton) dialog.view.findViewById(R.id.md_buttonDefaultNeutral);
-    dialog.negativeButton = (MDButton) dialog.view.findViewById(R.id.md_buttonDefaultNegative);
+    dialog.positiveButton = dialog.view.findViewById(R.id.md_buttonDefaultPositive);
+    dialog.neutralButton = dialog.view.findViewById(R.id.md_buttonDefaultNeutral);
+    dialog.negativeButton = dialog.view.findViewById(R.id.md_buttonDefaultNegative);
 
     // Don't allow the submit button to not be shown for input dialogs
     if (builder.inputCallback != null && builder.positiveText == null) {
@@ -355,7 +355,7 @@ class DialogInit {
     // Setup custom views
     if (builder.customView != null) {
       ((MDRootLayout) dialog.view.findViewById(R.id.md_root)).noTitleNoPadding();
-      FrameLayout frame = (FrameLayout) dialog.view.findViewById(R.id.md_customViewFrame);
+      FrameLayout frame = dialog.view.findViewById(R.id.md_customViewFrame);
       dialog.customViewFrame = frame;
       View innerView = builder.customView;
       if (innerView.getParent() != null) {
@@ -448,7 +448,7 @@ class DialogInit {
   private static void setupProgressDialog(final MaterialDialog dialog) {
     final MaterialDialog.Builder builder = dialog.builder;
     if (builder.indeterminateProgress || builder.progress > -2) {
-      dialog.progressBar = (ProgressBar) dialog.view.findViewById(android.R.id.progress);
+      dialog.progressBar = dialog.view.findViewById(android.R.id.progress);
       if (dialog.progressBar == null) {
         return;
       }
@@ -483,13 +483,13 @@ class DialogInit {
             builder.indeterminateProgress && builder.indeterminateIsHorizontalProgress);
         dialog.progressBar.setProgress(0);
         dialog.progressBar.setMax(builder.progressMax);
-        dialog.progressLabel = (TextView) dialog.view.findViewById(R.id.md_label);
+        dialog.progressLabel = dialog.view.findViewById(R.id.md_label);
         if (dialog.progressLabel != null) {
           dialog.progressLabel.setTextColor(builder.contentColor);
           dialog.setTypeface(dialog.progressLabel, builder.mediumFont);
           dialog.progressLabel.setText(builder.progressPercentFormat.format(0));
         }
-        dialog.progressMinMax = (TextView) dialog.view.findViewById(R.id.md_minMax);
+        dialog.progressMinMax = dialog.view.findViewById(R.id.md_minMax);
         if (dialog.progressMinMax != null) {
           dialog.progressMinMax.setTextColor(builder.contentColor);
           dialog.setTypeface(dialog.progressMinMax, builder.regularFont);
@@ -518,7 +518,7 @@ class DialogInit {
 
   private static void setupInputDialog(final MaterialDialog dialog) {
     final MaterialDialog.Builder builder = dialog.builder;
-    dialog.input = (EditText) dialog.view.findViewById(android.R.id.input);
+    dialog.input = dialog.view.findViewById(android.R.id.input);
     if (dialog.input == null) {
       return;
     }
@@ -543,7 +543,7 @@ class DialogInit {
       }
     }
 
-    dialog.inputMinMax = (TextView) dialog.view.findViewById(R.id.md_minMax);
+    dialog.inputMinMax = dialog.view.findViewById(R.id.md_minMax);
     if (builder.inputMinLength > 0 || builder.inputMaxLength > -1) {
       dialog.invalidateInputMinMaxIndicator(
           dialog.input.getText().toString().length(), !builder.inputAllowEmpty);

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

@@ -199,7 +199,7 @@ public class MaterialDialog extends DialogBase
     } else {
       // Default adapter, choice mode
       if (listType == ListType.MULTI) {
-        final CheckBox cb = (CheckBox) view.findViewById(R.id.md_control);
+        final CheckBox cb = view.findViewById(R.id.md_control);
         if (!cb.isEnabled()) {
           return false;
         }
@@ -236,7 +236,7 @@ public class MaterialDialog extends DialogBase
           }
         }
       } else if (listType == ListType.SINGLE) {
-        final RadioButton radio = (RadioButton) view.findViewById(R.id.md_control);
+        final RadioButton radio = view.findViewById(R.id.md_control);
         if (!radio.isEnabled()) {
           return false;
         }

+ 0 - 4
sample/src/main/AndroidManifest.xml

@@ -27,10 +27,6 @@
       android:label="@string/preference_dialogs"
       android:name=".PreferenceActivity" />
 
-    <activity
-      android:label="@string/preference_dialogs"
-      android:name=".PreferenceActivityCompat" />
-
   </application>
 
 </manifest>

+ 4 - 8
sample/src/main/java/com/afollestad/materialdialogssample/MainActivity.java

@@ -485,7 +485,7 @@ public class MainActivity extends AppCompatActivity
 
     positiveAction = dialog.getActionButton(DialogAction.POSITIVE);
     //noinspection ConstantConditions
-    passwordInput = (EditText) dialog.getCustomView().findViewById(R.id.password);
+    passwordInput = dialog.getCustomView().findViewById(R.id.password);
     passwordInput.addTextChangedListener(
         new TextWatcher() {
           @Override
@@ -501,7 +501,7 @@ public class MainActivity extends AppCompatActivity
         });
 
     // Toggling the show password CheckBox will mask or unmask the password input EditText
-    CheckBox checkbox = (CheckBox) dialog.getCustomView().findViewById(R.id.showPassword);
+    CheckBox checkbox = dialog.getCustomView().findViewById(R.id.showPassword);
     checkbox.setOnCheckedChangeListener(
         (buttonView, isChecked) -> {
           passwordInput.setInputType(
@@ -628,7 +628,7 @@ public class MainActivity extends AppCompatActivity
   public void showThemed() {
     new MaterialDialog.Builder(this)
         .title(R.string.useGoogleLocationServices)
-        .content(R.string.useGoogleLocationServicesPrompt)
+        .content(R.string.useGoogleLocationServicesPrompt, true)
         .positiveText(R.string.agree)
         .negativeText(R.string.disagree)
         .positiveColorRes(R.color.material_red_400)
@@ -841,11 +841,7 @@ public class MainActivity extends AppCompatActivity
 
   @OnClick(R.id.preference_dialogs)
   public void showPreferenceDialogs() {
-    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
-      startActivity(new Intent(getApplicationContext(), PreferenceActivity.class));
-    } else {
-      startActivity(new Intent(getApplicationContext(), PreferenceActivityCompat.class));
-    }
+    startActivity(new Intent(getApplicationContext(), PreferenceActivity.class));
   }
 
   @Override

+ 0 - 26
sample/src/main/java/com/afollestad/materialdialogssample/PreferenceActivityCompat.java

@@ -1,26 +0,0 @@
-package com.afollestad.materialdialogssample;
-
-import android.annotation.TargetApi;
-import android.os.Build;
-import android.os.Bundle;
-import android.view.MenuItem;
-
-@TargetApi(Build.VERSION_CODES.GINGERBREAD_MR1)
-public class PreferenceActivityCompat extends android.preference.PreferenceActivity {
-
-  @SuppressWarnings("deprecation")
-  @Override
-  protected void onCreate(Bundle savedInstanceState) {
-    super.onCreate(savedInstanceState);
-    addPreferencesFromResource(R.xml.preferences);
-  }
-
-  @Override
-  public boolean onOptionsItemSelected(MenuItem item) {
-    if (item.getItemId() == android.R.id.home) {
-      onBackPressed();
-      return true;
-    }
-    return super.onOptionsItemSelected(item);
-  }
-}