use of android.view.ContextThemeWrapper in project platform_frameworks_base by android.
the class ListMenuPresenter method initForMenu.
@Override
public void initForMenu(@NonNull Context context, @Nullable MenuBuilder menu) {
if (mThemeRes != 0) {
mContext = new ContextThemeWrapper(context, mThemeRes);
mInflater = LayoutInflater.from(mContext);
} else if (mContext != null) {
mContext = context;
if (mInflater == null) {
mInflater = LayoutInflater.from(mContext);
}
}
mMenu = menu;
if (mAdapter != null) {
mAdapter.notifyDataSetChanged();
}
}
use of android.view.ContextThemeWrapper in project platform_frameworks_base by android.
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(displayContext);
return new ContextThemeWrapper(displayContext, theme) {
@Override
public Object getSystemService(String name) {
if (Context.WINDOW_SERVICE.equals(name)) {
return displayWindowManager;
}
return super.getSystemService(name);
}
};
}
use of android.view.ContextThemeWrapper in project platform_frameworks_base by android.
the class FloatingToolbar method applyDefaultTheme.
/**
* Returns a re-themed context with controlled look and feel for views.
*/
private static Context applyDefaultTheme(Context originalContext) {
TypedArray a = originalContext.obtainStyledAttributes(new int[] { R.attr.isLightTheme });
boolean isLightTheme = a.getBoolean(0, true);
int themeId = isLightTheme ? R.style.Theme_Material_Light : R.style.Theme_Material;
a.recycle();
return new ContextThemeWrapper(originalContext, themeId);
}
use of android.view.ContextThemeWrapper in project danci by ling0322.
the class ReciteFragment method onStartButtonClicked.
private void onStartButtonClicked() {
state = FIRST;
recite.start();
if (recite.isFinsihed() == true) {
Dialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.AnneDialog)).setMessage("今天的单词都背完了哦,明天继续复习吧:)").setNegativeButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
}
}).create();
dialog.show();
} else {
showTestButtons();
updateDiaplay();
}
}
use of android.view.ContextThemeWrapper in project danci by ling0322.
the class ReciteFragment method onBackKey.
@Override
public boolean onBackKey() {
if (recite.isFinsihed() == true) {
System.exit(0);
}
Dialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.AnneDialog)).setMessage("单词还没有背完, 确定要退出吗?").setPositiveButton("退出", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
System.exit(0);
}
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
}
}).create();
dialog.show();
return true;
}
Aggregations