Browse Source

Dialog custom view theme issues should be fixed?

Aidan Follestad 10 years ago
parent
commit
33a4006041

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

@@ -8,7 +8,6 @@ import android.graphics.Color;
 import android.graphics.drawable.Drawable;
 import android.os.Build;
 import android.text.method.LinkMovementMethod;
-import android.view.ContextThemeWrapper;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.inputmethod.InputMethodManager;
@@ -36,13 +35,13 @@ import java.util.Arrays;
  */
 class DialogInit {
 
-    public static ContextThemeWrapper getTheme(MaterialDialog.Builder builder) {
+    public static int getTheme(MaterialDialog.Builder builder) {
         boolean darkTheme = builder.theme == Theme.DARK;
         if (!darkTheme) {
             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);
+        return darkTheme ? R.style.MD_Dark : R.style.MD_Light;
     }
 
     public static int getInflateLayout(MaterialDialog.Builder builder) {

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

@@ -76,7 +76,7 @@ public class MaterialDialog extends DialogBase implements
 
     @SuppressLint("InflateParams")
     protected MaterialDialog(Builder builder) {
-        super(DialogInit.getTheme(builder));
+        super(builder.context, DialogInit.getTheme(builder));
         mBuilder = builder;
         final LayoutInflater inflater = LayoutInflater.from(mBuilder.context);
         view = (MDRootLayout) inflater.inflate(DialogInit.getInflateLayout(builder), null);

+ 2 - 2
library/src/main/java/com/afollestad/materialdialogs/base/DialogBase.java

@@ -13,8 +13,8 @@ import android.view.ViewGroup;
 public class DialogBase extends AlertDialog implements DialogInterface.OnShowListener {
     private OnShowListener mShowListener;
 
-    protected DialogBase(Context context) {
-        super(context);
+    protected DialogBase(Context context, int theme) {
+        super(context, theme);
     }
 
     protected void setVerticalMargins(View view, int topMargin, int bottomMargin) {