浏览代码

Simplified getTheme() process in DialogInit using DialogUtils.resolveBoolean()

Aidan Follestad 10 年之前
父节点
当前提交
b3e1c547f2
共有 1 个文件被更改,包括 2 次插入9 次删除
  1. 2 9
      library/src/main/java/com/afollestad/materialdialogs/DialogInit.java

+ 2 - 9
library/src/main/java/com/afollestad/materialdialogs/DialogInit.java

@@ -4,9 +4,7 @@ import android.content.Context;
 import android.content.DialogInterface;
 import android.content.res.ColorStateList;
 import android.content.res.Resources;
-import android.content.res.TypedArray;
 import android.graphics.Color;
-import android.graphics.PorterDuff;
 import android.graphics.drawable.Drawable;
 import android.os.Build;
 import android.text.method.LinkMovementMethod;
@@ -39,15 +37,10 @@ import java.util.Arrays;
 class DialogInit {
 
     public static ContextThemeWrapper getTheme(MaterialDialog.Builder builder) {
-        TypedArray a = builder.context.getTheme().obtainStyledAttributes(new int[]{R.attr.md_dark_theme});
         boolean darkTheme = builder.theme == Theme.DARK;
         if (!darkTheme) {
-            try {
-                darkTheme = a.getBoolean(0, false);
-                builder.theme = darkTheme ? Theme.DARK : Theme.LIGHT;
-            } finally {
-                a.recycle();
-            }
+            darkTheme = DialogUtils.resolveBoolean(builder.context, R.attr.md_dark_theme, false);
+            builder.theme = darkTheme ? Theme.DARK : Theme.LIGHT;
         }
         return new ContextThemeWrapper(builder.context, darkTheme ? R.style.MD_Dark : R.style.MD_Light);
     }