use of android.view.ContextThemeWrapper in project SublimePicker by vikramkakkar.
the class SUtils method createThemeWrapper.
public static ContextThemeWrapper createThemeWrapper(Context context, int parentStyleAttr, int parentDefaultStyle, int childStyleAttr, int childDefaultStyle) {
final TypedArray forParent = context.obtainStyledAttributes(new int[] { parentStyleAttr });
int parentStyle = forParent.getResourceId(0, parentDefaultStyle);
forParent.recycle();
TypedArray forChild = context.obtainStyledAttributes(parentStyle, new int[] { childStyleAttr });
int childStyleId = forChild.getResourceId(0, childDefaultStyle);
forChild.recycle();
return new ContextThemeWrapper(context, childStyleId);
}
use of android.view.ContextThemeWrapper in project SublimePicker by vikramkakkar.
the class SublimePicker method createThemeWrapper.
private static ContextThemeWrapper createThemeWrapper(Context context) {
final TypedArray forParent = context.obtainStyledAttributes(new int[] { R.attr.sublimePickerStyle });
int parentStyle = forParent.getResourceId(0, R.style.SublimePickerStyleLight);
forParent.recycle();
return new ContextThemeWrapper(context, parentStyle);
}
use of android.view.ContextThemeWrapper in project AndroidChromium by JackyAndroid.
the class WarmupManager method initializeViewHierarchy.
/**
* Inflates and constructs the view hierarchy that the app will use.
* @param baseContext The base context to use for creating the ContextWrapper.
* @param toolbarContainerId Id of the toolbar container.
*/
public void initializeViewHierarchy(Context baseContext, int toolbarContainerId) {
TraceEvent.begin("WarmupManager.initializeViewHierarchy");
// Inflating the view hierarchy causes StrictMode violations on some
// devices. Since layout inflation should happen on the UI thread, allow
// the disk reads. crbug.com/644243.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
try {
ThreadUtils.assertOnUiThread();
if (mMainView != null && mToolbarContainerId == toolbarContainerId)
return;
ContextThemeWrapper context = new ContextThemeWrapper(baseContext, ChromeActivity.getThemeId());
FrameLayout contentHolder = new FrameLayout(context);
mMainView = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.main, contentHolder);
mToolbarContainerId = toolbarContainerId;
if (toolbarContainerId != ChromeActivity.NO_CONTROL_CONTAINER) {
ViewStub stub = (ViewStub) mMainView.findViewById(R.id.control_container_stub);
stub.setLayoutResource(toolbarContainerId);
stub.inflate();
}
} catch (InflateException e) {
// See crbug.com/606715.
Log.e(TAG, "Inflation exception.", e);
mMainView = null;
} finally {
StrictMode.setThreadPolicy(oldPolicy);
TraceEvent.end("WarmupManager.initializeViewHierarchy");
}
}
use of android.view.ContextThemeWrapper in project android_frameworks_base by ParanoidAndroid.
the class ActionBarImpl method getThemedContext.
public Context getThemedContext() {
if (mThemedContext == null) {
TypedValue outValue = new TypedValue();
Resources.Theme currentTheme = mContext.getTheme();
currentTheme.resolveAttribute(com.android.internal.R.attr.actionBarWidgetTheme, outValue, true);
final int targetThemeRes = outValue.resourceId;
if (targetThemeRes != 0 && mContext.getThemeResId() != targetThemeRes) {
mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes);
} else {
mThemedContext = mContext;
}
}
return mThemedContext;
}
use of android.view.ContextThemeWrapper in project android_frameworks_base by ParanoidAndroid.
the class Presentation method createPresentationContext.
private static Context createPresentationContext(Context outerContext, Display display, int theme) {
if (outerContext == null) {
throw new IllegalArgumentException("outerContext must not be null");
}
if (display == null) {
throw new IllegalArgumentException("display must not be null");
}
Context displayContext = outerContext.createDisplayContext(display);
if (theme == 0) {
TypedValue outValue = new TypedValue();
displayContext.getTheme().resolveAttribute(com.android.internal.R.attr.presentationTheme, outValue, true);
theme = outValue.resourceId;
}
// Derive the display's window manager from the outer window manager.
// We do this because the outer window manager have some extra information
// such as the parent window, which is important if the presentation uses
// an application window type.
final WindowManagerImpl outerWindowManager = (WindowManagerImpl) outerContext.getSystemService(Context.WINDOW_SERVICE);
final WindowManagerImpl displayWindowManager = outerWindowManager.createPresentationWindowManager(display);
return new ContextThemeWrapper(displayContext, theme) {
@Override
public Object getSystemService(String name) {
if (Context.WINDOW_SERVICE.equals(name)) {
return displayWindowManager;
}
return super.getSystemService(name);
}
};
}
Aggregations