本文整理汇总了Java中android.support.v7.view.ContextThemeWrapper类的典型用法代码示例。如果您正苦于以下问题:Java ContextThemeWrapper类的具体用法?Java ContextThemeWrapper怎么用?Java ContextThemeWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContextThemeWrapper类属于android.support.v7.view包,在下文中一共展示了ContextThemeWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
public static TintManager get(Context context) {
if (context == null) return null;
if (context instanceof ContextThemeWrapper) {
context = ((ContextThemeWrapper) context).getBaseContext();
}
if (context instanceof android.view.ContextThemeWrapper) {
context = ((android.view.ContextThemeWrapper) context).getBaseContext();
}
TintManager tm = INSTANCE_CACHE.get(context);
if (tm == null) {
tm = new TintManager(context);
INSTANCE_CACHE.put(context, tm);
printLog("[getBaseApplication TintManager] create new TintManager.");
}
return tm;
}
示例2: onCreateView
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final Context contextThemeWrapper = new ContextThemeWrapper(getContext(), getContext().getTheme());
LayoutInflater themeAwareInflater = inflater.cloneInContext(contextThemeWrapper);
View view = themeAwareInflater.inflate(layoutRes(), container, false);
unbinder = ButterKnife.bind(this, view);
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override public void onGlobalLayout() {
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
View parent = getDialog().findViewById(R.id.design_bottom_sheet);
if (parent != null) {
bottomSheetBehavior = BottomSheetBehavior.from(parent);
if (bottomSheetBehavior != null) {
bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
}
}
});
return view;
}
示例3: onPrepareOptionsMenu
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
mToolbar.getMenu()
.findItem(R.id.theme)
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
int style = new ColorPreferences(FeedViewSingle.this).getThemeSubreddit(
feed);
final Context contextThemeWrapper =
new ContextThemeWrapper(FeedViewSingle.this, style);
LayoutInflater localInflater =
getLayoutInflater().cloneInContext(contextThemeWrapper);
final View dialoglayout = localInflater.inflate(R.layout.colorsub, null);
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add(feed);
Palette.showSubThemeEditor(arrayList, FeedViewSingle.this,
dialoglayout);
return false;
}
});
return true;
}
示例4: onPrepareOptionsMenu
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
this.menu = menu;
menu.findItem(R.id.theme)
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
int style = new ColorPreferences(MainActivity.this).getThemeSubreddit(
selectedFeed.getTitle());
final Context contextThemeWrapper =
new ContextThemeWrapper(MainActivity.this, style);
LayoutInflater localInflater =
getLayoutInflater().cloneInContext(contextThemeWrapper);
final View dialoglayout =
localInflater.inflate(R.layout.colorsub, null);
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add(selectedFeed.getTitle());
Palette.showSubThemeEditor(arrayList, MainActivity.this,
dialoglayout);
return false;
}
});
return true;
}
示例5: setStyle
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
void setStyle(Context context) {
TypedValue outValue = new TypedValue();
Theme widgetTheme = context.getResources().newTheme();
widgetTheme.setTo(context.getTheme());
widgetTheme.resolveAttribute(R.attr.actionBarPopupTheme, outValue, true);
if (outValue.resourceId != 0) {
widgetTheme.applyStyle(outValue.resourceId, true);
}
widgetTheme.resolveAttribute(R.attr.panelMenuListTheme, outValue, true);
if (outValue.resourceId != 0) {
widgetTheme.applyStyle(outValue.resourceId, true);
} else {
widgetTheme.applyStyle(R.style.Theme_AppCompat_CompactMenu, true);
}
Context context2 = new ContextThemeWrapper(context, 0);
context2.getTheme().setTo(widgetTheme);
this.listPresenterContext = context2;
TypedArray a = context2.obtainStyledAttributes(R.styleable.AppCompatTheme);
this.background = a.getResourceId(R.styleable.AppCompatTheme_panelBackground, 0);
this.windowAnimations = a.getResourceId(R.styleable.AppCompatTheme_android_windowAnimationStyle, 0);
a.recycle();
}
示例6: initializePanelMenu
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
private boolean initializePanelMenu(PanelFeatureState st) {
Context context = this.mContext;
if ((st.featureId == 0 || st.featureId == 108) && this.mDecorContentParent != null) {
TypedValue outValue = new TypedValue();
Theme baseTheme = context.getTheme();
baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
Theme widgetTheme = null;
if (outValue.resourceId != 0) {
widgetTheme = context.getResources().newTheme();
widgetTheme.setTo(baseTheme);
widgetTheme.applyStyle(outValue.resourceId, true);
widgetTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
} else {
baseTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
}
if (outValue.resourceId != 0) {
if (widgetTheme == null) {
widgetTheme = context.getResources().newTheme();
widgetTheme.setTo(baseTheme);
}
widgetTheme.applyStyle(outValue.resourceId, true);
}
if (widgetTheme != null) {
Context context2 = new ContextThemeWrapper(context, 0);
context2.getTheme().setTo(widgetTheme);
context = context2;
}
}
MenuBuilder menu = new MenuBuilder(context);
menu.setCallback(this);
st.setMenu(menu);
return true;
}
示例7: themifyContext
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
private static Context themifyContext(Context context, AttributeSet attrs, boolean useAndroidTheme, boolean useAppTheme) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.View, 0, 0);
int themeId = 0;
if (useAndroidTheme) {
themeId = a.getResourceId(R.styleable.View_android_theme, 0);
}
if (useAppTheme && themeId == 0) {
themeId = a.getResourceId(R.styleable.View_theme, 0);
if (themeId != 0) {
Log.i(LOG_TAG, "app:theme is now deprecated. Please move to using android:theme instead.");
}
}
a.recycle();
if (themeId == 0) {
return context;
}
if ((context instanceof ContextThemeWrapper) && ((ContextThemeWrapper) context).getThemeResId() == themeId) {
return context;
}
return new ContextThemeWrapper(context, themeId);
}
示例8: showDialogMessage
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
/**
* Common method to show message in alert box.
*
* @param title the title
* @param body the body
*/
public void showDialogMessage(String title, String body,Context context) {
final AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.myDialog));
builder.setTitle(title).setMessage(body).setNeutralButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
mUserDialog.dismiss();
} catch (Exception e) {
Log.e(AppUtility.TAG, Log.getStackTraceString(e));
}
}
});
mUserDialog = builder.create();
mUserDialog.show();
}
示例9: showDialogMessage
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
private void showDialogMessage(String title, String body, final boolean exit) {
final AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.myDialog));
builder.setTitle(title).setMessage(body).setNeutralButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
muserDialog.dismiss();
if (exit) {
exit(mUsernameInput);
}
} catch (Exception e) {
Log.e(AppUtility.TAG, Log.getStackTraceString(e));
if (exit) {
exit(mUsernameInput);
}
}
}
});
muserDialog = builder.create();
muserDialog.show();
}
示例10: get
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
public static com.bilibili.magicasakura.utils.TintManager get(Context context) {
if (context == null) return null;
if (context instanceof ContextThemeWrapper) {
context = ((ContextThemeWrapper) context).getBaseContext();
}
if (context instanceof android.view.ContextThemeWrapper) {
context = ((android.view.ContextThemeWrapper) context).getBaseContext();
}
com.bilibili.magicasakura.utils.TintManager tm = INSTANCE_CACHE.get(context);
if (tm == null) {
tm = new com.bilibili.magicasakura.utils.TintManager(context);
INSTANCE_CACHE.put(context, tm);
printLog("[get TintManager] create new TintManager.");
}
return tm;
}
示例11: onCreate
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//apply activity's theme if dark theme is enabled
themeWrapper = new ContextThemeWrapper(getBaseContext(), this.getTheme());
Preferences.applyTheme(themeWrapper, getBaseContext());
setContentView(R.layout.preference_activity);
//provide back navigation
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
if (getFragmentManager().findFragmentById(R.id.content_frame) == null) {
SettingsFragment settingsFragment = new SettingsFragment();
getFragmentManager().beginTransaction().replace(R.id.content_frame, settingsFragment).commit();
}
}
示例12: inflateDebugging
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
@SuppressLint("InflateParams")
private void inflateDebugging() {
mDebuggingText = (TextView) LayoutInflater.from(new ContextThemeWrapper(mService, R.style.Theme_Velociraptor))
.inflate(R.layout.floating_stats, null, false);
WindowManager.LayoutParams debuggingParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT,
getWindowType(),
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
PixelFormat.TRANSLUCENT);
debuggingParams.gravity = Gravity.BOTTOM;
try {
mWindowManager.addView(mDebuggingText, debuggingParams);
} catch (Exception e) {
mService.showToast("Velociraptor error: " + e.getMessage());
}
}
示例13: onCreateView
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
@Override
@SuppressLint("RestrictedApi")
public View onCreateView(String name, Context context, AttributeSet attrs) {
final Resources.Theme theme = context.getTheme();
switch (name) {
case "Button":
return new PandroidCompatButton(new ContextThemeWrapper(context, theme), attrs);
case "EditText":
return new PandroidCompatEditText(new ContextThemeWrapper(context, theme), attrs);
case "RadioButton":
return new PandroidCompatEditText(new ContextThemeWrapper(context, theme), attrs);
case "Switch":
return new PandroidCompatSwitch(new ContextThemeWrapper(context, theme), attrs);
case "TextView":
return new PandroidCompatTextView(new ContextThemeWrapper(context, theme), attrs);
case "ToggleButton":
return new ToggleButton(new ContextThemeWrapper(context, theme), attrs);
default:
return null;
}
}
示例14: show_ok_dialog
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
public static void show_ok_dialog(final Activity activity, String title, String message, final Runnable runnable) {
try {
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.AppTheme));
builder.setTitle(title);
builder.setMessage(message);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (runnable != null) {
runOnUiThreadDelayed(runnable, 10);
}
}
});
builder.create().show();
} catch (Exception e) {
Log.wtf(TAG, "show_dialog exception: " + e);
static_toast_long(message);
}
}
示例15: onPreferenceTreeClick
import android.support.v7.view.ContextThemeWrapper; //导入依赖的package包/类
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference.getKey().equals("delete_all")) {
File myDownloads = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS);
// Add them to a list first before we sort them.
deleteApks(myDownloads);
Toast.makeText(getActivity(), R.string.downloaded_files_deleted, Toast.LENGTH_SHORT).show();
} else if (preference.getKey().equals("build_variant")) {
new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.dialog_theme))
.setTitle(R.string.title_app_variants)
.setMessage(R.string.build_variant_explanation)
.show();
}
return super.onPreferenceTreeClick(preference);
}