You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
38 lines
724 B
Java
38 lines
724 B
Java
package android.view;
|
|
|
|
import android.content.Context;
|
|
import android.content.ContextWrapper;
|
|
import android.content.res.Resources;
|
|
|
|
public class ContextThemeWrapper extends ContextWrapper {
|
|
|
|
private Resources.Theme theme = null;
|
|
|
|
public ContextThemeWrapper(Context base) {
|
|
super(base);
|
|
}
|
|
|
|
public ContextThemeWrapper(Context context, int themeResId) {
|
|
super(context);
|
|
setTheme(themeResId);
|
|
}
|
|
|
|
@Override
|
|
public void setTheme(int resid) {
|
|
if (theme == null) {
|
|
theme = getResources().newTheme();
|
|
theme.setTo(getBaseContext().getTheme());
|
|
}
|
|
theme.applyStyle(resid, true);
|
|
}
|
|
|
|
@Override
|
|
public Resources.Theme getTheme() {
|
|
if (theme != null)
|
|
return theme;
|
|
else
|
|
return super.getTheme();
|
|
}
|
|
|
|
}
|