Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7124cdd authored by Fabrice Di Meglio's avatar Fabrice Di Meglio Committed by Android (Google) Code Review
Browse files

Merge "Cleanup ContextThemeWrapper"

parents c8dbd29f ebb9f3a1
Loading
Loading
Loading
Loading
+3 −6
Original line number Original line Diff line number Diff line
@@ -26,7 +26,6 @@ import android.content.res.Resources;
 * wrapped context. 
 * wrapped context. 
 */
 */
public class ContextThemeWrapper extends ContextWrapper {
public class ContextThemeWrapper extends ContextWrapper {
    private Context mBase;
    private int mThemeResource;
    private int mThemeResource;
    private Resources.Theme mTheme;
    private Resources.Theme mTheme;
    private LayoutInflater mInflater;
    private LayoutInflater mInflater;
@@ -39,13 +38,11 @@ public class ContextThemeWrapper extends ContextWrapper {
    
    
    public ContextThemeWrapper(Context base, int themeres) {
    public ContextThemeWrapper(Context base, int themeres) {
        super(base);
        super(base);
        mBase = base;
        mThemeResource = themeres;
        mThemeResource = themeres;
    }
    }


    @Override protected void attachBaseContext(Context newBase) {
    @Override protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(newBase);
        super.attachBaseContext(newBase);
        mBase = newBase;
    }
    }


    /**
    /**
@@ -109,11 +106,11 @@ public class ContextThemeWrapper extends ContextWrapper {
    @Override public Object getSystemService(String name) {
    @Override public Object getSystemService(String name) {
        if (LAYOUT_INFLATER_SERVICE.equals(name)) {
        if (LAYOUT_INFLATER_SERVICE.equals(name)) {
            if (mInflater == null) {
            if (mInflater == null) {
                mInflater = LayoutInflater.from(mBase).cloneInContext(this);
                mInflater = LayoutInflater.from(getBaseContext()).cloneInContext(this);
            }
            }
            return mInflater;
            return mInflater;
        }
        }
        return mBase.getSystemService(name);
        return getBaseContext().getSystemService(name);
    }
    }
    
    
    /**
    /**
@@ -135,7 +132,7 @@ public class ContextThemeWrapper extends ContextWrapper {
        final boolean first = mTheme == null;
        final boolean first = mTheme == null;
        if (first) {
        if (first) {
            mTheme = getResources().newTheme();
            mTheme = getResources().newTheme();
            Resources.Theme theme = mBase.getTheme();
            Resources.Theme theme = getBaseContext().getTheme();
            if (theme != null) {
            if (theme != null) {
                mTheme.setTo(theme);
                mTheme.setTo(theme);
            }
            }