本文整理匯總了Java中android.view.ContextThemeWrapper類的典型用法代碼示例。如果您正苦於以下問題:Java ContextThemeWrapper類的具體用法?Java ContextThemeWrapper怎麽用?Java ContextThemeWrapper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ContextThemeWrapper類屬於android.view包,在下文中一共展示了ContextThemeWrapper類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ScriptListNavigatorContent
import android.view.ContextThemeWrapper; //導入依賴的package包/類
public ScriptListNavigatorContent(Context context) {
mScriptListWithProgressBarView = new ScriptListWithProgressBarView(new ContextThemeWrapper(context, R.style.AppTheme));
mFloatingScriptFileListView = mScriptListWithProgressBarView.getScriptAndFolderListRecyclerView();
mFloatingScriptFileListView.setViewHolderSupplier(mViewHolderSupplier);
mFloatingScriptFileListView.setLayoutManager(new WrapContentLinearLayoutManager(context));
mFloatingScriptFileListView.setStorageScriptProvider(StorageScriptProvider.getDefault());
mFloatingScriptFileListView.setOnItemClickListener(new ScriptAndFolderListRecyclerView.OnScriptFileClickListener() {
@Override
public void onClick(ScriptFile file, int position) {
Scripts.run(file);
HoverMenuService.postIntent(new Intent(HoverMenuService.ACTION_COLLAPSE_MENU));
}
});
}
開發者ID:feifadaima,項目名稱:https-github.com-hyb1996-NoRootScriptDroid,代碼行數:17,代碼來源:ScriptListNavigatorContent.java
示例2: PendingAppWidgetHostView
import android.view.ContextThemeWrapper; //導入依賴的package包/類
public PendingAppWidgetHostView(Context context, LauncherAppWidgetInfo info,
IconCache cache, boolean disabledForSafeMode) {
super(new ContextThemeWrapper(context, R.style.WidgetContainerTheme));
mLauncher = Launcher.getLauncher(context);
mInfo = info;
mStartState = info.restoreStatus;
mDisabledForSafeMode = disabledForSafeMode;
mPaint = new TextPaint();
mPaint.setColor(ThemeUtils.getAttrColor(getContext(), android.R.attr.textColorPrimary));
mPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,
mLauncher.getDeviceProfile().iconTextSizePx, getResources().getDisplayMetrics()));
setBackgroundResource(R.drawable.pending_widget_bg);
setWillNotDraw(false);
setElevation(getResources().getDimension(R.dimen.pending_widget_elevation));
updateAppWidget(null);
setOnClickListener(mLauncher);
// Load icon
PackageItemInfo item = new PackageItemInfo(info.providerName.getPackageName());
item.user = info.user;
cache.updateIconInBackground(this, item);
}
示例3: IconAdapter
import android.view.ContextThemeWrapper; //導入依賴的package包/類
IconAdapter(Context context, Map<String, IconPackInfo> supportedPackages, String currentPack) {
int theme = PreferencesState.isDarkThemeEnabled(context)? R.style.DialogStyleDark : R.style.DialogStyle;
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, theme);
mLayoutInflater = LayoutInflater.from(contextThemeWrapper);
mSupportedPackages = new ArrayList<>(supportedPackages.values());
Collections.sort(mSupportedPackages, new Comparator<IconPackInfo>() {
@Override
public int compare(IconPackInfo lhs, IconPackInfo rhs) {
return lhs.label.toString().compareToIgnoreCase(rhs.label.toString());
}
});
Resources res = context.getResources();
String defaultLabel = res.getString(R.string.default_iconpack_title);
Drawable icon = ContextCompat.getDrawable(context, R.mipmap.ic_default_icon_pack);
mSupportedPackages.add(0, new IconPackInfo(defaultLabel, icon, ""));
mCurrentIconPack = currentPack;
}
示例4: pullFontPathFromTextAppearance
import android.view.ContextThemeWrapper; //導入依賴的package包/類
/**
* Tries to pull the Font Path from the Text Appearance.
*
* @param context Activity Context
* @param attrs View Attributes
* @param attributeId if -1 returns null.
* @return returns null if attribute is not defined or if no TextAppearance is found.
*/
@FontRes
static int pullFontPathFromTextAppearance(final Context context, AttributeSet attrs, int[] attributeId) {
if (attributeId == null || attrs == null)
return 0;
int textAppearanceId = -1;
// For prevent using default component font
final ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, android.R.style.Theme_NoDisplay);
final TypedArray typedArrayAttr = contextThemeWrapper.obtainStyledAttributes(attrs, ANDROID_ATTR_TEXT_APPEARANCE);
if (typedArrayAttr != null) {
try {
textAppearanceId = typedArrayAttr.getResourceId(0, 0);
} catch (Exception ignored) {
// Failed for some reason
return 0;
} finally {
typedArrayAttr.recycle();
}
}
final Integer textAppearanceAttrs = getFontFromTextAppearance(context, attributeId, textAppearanceId);
if (textAppearanceAttrs != null) return textAppearanceAttrs;
return 0;
}
示例5: createLabels
import android.view.ContextThemeWrapper; //導入依賴的package包/類
private void createLabels() {
Context context = new ContextThemeWrapper(getContext(), mLabelsStyle);
for (int i = 0; i < mButtonsCount; i++) {
FloatingActionButtonLibrary button = (FloatingActionButtonLibrary) getChildAt(i);
String title = button.getTitle();
if (button == mAddButton || title == null ||
button.getTag(R.id.fab_label) != null) continue;
TextView label = new TextView(context);
label.setTextAppearance(getContext(), mLabelsStyle);
label.setText(button.getTitle());
addView(label);
button.setTag(R.id.fab_label, label);
}
}
示例6: createLabels
import android.view.ContextThemeWrapper; //導入依賴的package包/類
private void createLabels() {
Context context = new ContextThemeWrapper(getContext(), mLabelsStyle);
for (int i = 0; i < mButtonsCount; i++) {
FloatingActionButton button = (FloatingActionButton) getChildAt(i);
String title = button.getTitle();
if (button == mAddButton || title == null ||
button.getTag(R.id.fab_label) != null) continue;
TextView label = new TextView(context);
label.setTextAppearance(getContext(), mLabelsStyle);
label.setText(button.getTitle());
addView(label);
button.setTag(R.id.fab_label, label);
}
}
示例7: inflateView
import android.view.ContextThemeWrapper; //導入依賴的package包/類
@Override
protected View inflateView(FloatyService service) {
mContext = new ContextThemeWrapper(service, R.style.AppTheme);
mLayoutBoundsView = new LayoutBoundsView(mContext) {
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
close();
return true;
}
return super.dispatchKeyEvent(event);
}
};
setupView();
return mLayoutBoundsView;
}
示例8: inflateView
import android.view.ContextThemeWrapper; //導入依賴的package包/類
@Override
protected View inflateView(FloatyService service) {
mContext = new ContextThemeWrapper(service, R.style.AppTheme);
mLayoutHierarchyView = new LayoutHierarchyView(mContext) {
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
close();
return true;
}
return super.dispatchKeyEvent(event);
}
};
setupView();
return mLayoutHierarchyView;
}
示例9: initFloaty
import android.view.ContextThemeWrapper; //導入依賴的package包/類
private void initFloaty() {
mWindow = new CircularActionMenuFloatingWindow(new CircularActionMenuFloaty() {
@Override
public View inflateActionView(FloatyService service, CircularActionMenuFloatingWindow window) {
View actionView = View.inflate(service, R.layout.circular_action_view, null);
mActionViewIcon = (ImageView) actionView.findViewById(R.id.icon);
return actionView;
}
@Override
public CircularActionMenu inflateMenuItems(FloatyService service, CircularActionMenuFloatingWindow window) {
CircularActionMenu menu = (CircularActionMenu) View.inflate(new ContextThemeWrapper(service, R.style.AppTheme), R.layout.circular_action_menu, null);
ButterKnife.bind(CircularMenu.this, menu);
return menu;
}
});
mWindow.setKeepToSideHiddenWidthRadio(0.25f);
FloatyService.addWindow(mWindow);
}
示例10: popFilterMenu
import android.view.ContextThemeWrapper; //導入依賴的package包/類
public void popFilterMenu(View rootview) {
int style = ResHelper.getStyleRes(getContext(), "BBS_PopupMenu");
Context wrapper = new ContextThemeWrapper(getContext(), style);
//Creating the instance of PopupMenu
PopupMenu popup = new PopupMenu(wrapper, rootview);
//Inflating the Popup using xml file
popup.getMenuInflater().inflate(PageForumThreadDetail.getMenuRes(getContext(), "bbs_popup_forumthread"), popup.getMenu());
//registering popup with OnMenuItemClickListener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
//only one menu item.
if (item.getItemId() == ResHelper.getIdRes(getContext(), "action_arrangebycomment")) {
orderType = ThreadListOrderType.LAST_POST;
performPullingDown(true);
} else if (item.getItemId() == ResHelper.getIdRes(getContext(), "action_arrangebypost")) {
orderType = ThreadListOrderType.CREATE_ON;
performPullingDown(true);
}
return true;
}
});
popup.show();
}
示例11: onCreate
import android.view.ContextThemeWrapper; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActivity().setTitle(R.string.prefs_about_chrome);
addPreferencesFromResource(R.xml.about_chrome_preferences);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
ChromeBasePreference deprecationWarning = new ChromeBasePreference(
new ContextThemeWrapper(getActivity(),
R.style.DeprecationWarningPreferenceTheme));
deprecationWarning.setOrder(-1);
deprecationWarning.setTitle(R.string.deprecation_warning);
deprecationWarning.setIcon(R.drawable.exclamation_triangle);
getPreferenceScreen().addPreference(deprecationWarning);
}
PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance();
AboutVersionStrings versionStrings = prefServiceBridge.getAboutVersionStrings();
Preference p = findPreference(PREF_APPLICATION_VERSION);
p.setSummary(getApplicationVersion(getActivity(), versionStrings.getApplicationVersion()));
p = findPreference(PREF_OS_VERSION);
p.setSummary(versionStrings.getOSVersion());
p = findPreference(PREF_LEGAL_INFORMATION);
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
p.setSummary(getString(R.string.legal_information_summary, currentYear));
}
示例12: callActivityOnCreate
import android.view.ContextThemeWrapper; //導入依賴的package包/類
@Override
public void callActivityOnCreate(Activity activity, Bundle icicle) {
final Intent intent = activity.getIntent();
if (PluginUtil.isIntentFromPlugin(intent)) {
Context base = activity.getBaseContext();
try {
LoadedPlugin plugin = this.mPluginManager.getLoadedPlugin(intent);
ReflectUtil.setField(base.getClass(), base, "mResources", plugin.getResources());
ReflectUtil.setField(ContextWrapper.class, activity, "mBase", plugin.getPluginContext());
ReflectUtil.setField(Activity.class, activity, "mApplication", plugin.getApplication());
ReflectUtil.setFieldNoException(ContextThemeWrapper.class, activity, "mBase", plugin.getPluginContext());
// set screenOrientation
ActivityInfo activityInfo = plugin.getActivityInfo(PluginUtil.getComponent(intent));
if (activityInfo.screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
activity.setRequestedOrientation(activityInfo.screenOrientation);
}
} catch (Exception e) {
e.printStackTrace();
}
}
mBase.callActivityOnCreate(activity, icicle);
}
示例13: inflateLayout
import android.view.ContextThemeWrapper; //導入依賴的package包/類
/**
* Inflates the layout.
*
* @param tabsOnly
* True, if only the tabs should be inflated, false otherwise
*/
public final void inflateLayout(final boolean tabsOnly) {
int themeResourceId = style.getThemeHelper().getThemeResourceId(tabSwitcher.getLayout());
LayoutInflater inflater =
LayoutInflater.from(new ContextThemeWrapper(getContext(), themeResourceId));
onInflateLayout(inflater, tabsOnly);
registerEventHandlerCallbacks();
adaptDecorator();
adaptLogLevel();
if (!tabsOnly) {
adaptToolbarVisibility();
adaptToolbarTitle();
adaptToolbarNavigationIcon();
inflateToolbarMenu();
}
}
示例14: showTelescopeDialog
import android.view.ContextThemeWrapper; //導入依賴的package包/類
public void showTelescopeDialog(final Activity activity) {
LayoutInflater inflater = LayoutInflater.from(activity);
TelescopeLayout content =
(TelescopeLayout) inflater.inflate(R.layout.telescope_tutorial_dialog, null);
final AlertDialog dialog =
new AlertDialog.Builder(activity).setView(content).setCancelable(false).create();
content.setLens(new Lens() {
@Override public void onCapture(File file) {
dialog.dismiss();
Context toastContext = new ContextThemeWrapper(activity, android.R.style.Theme_DeviceDefault_Dialog);
LayoutInflater toastInflater = LayoutInflater.from(toastContext);
Toast toast = Toast.makeText(toastContext, "", Toast.LENGTH_SHORT);
View toastView = toastInflater.inflate(R.layout.telescope_tutorial_toast, null);
toast.setView(toastView);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
});
dialog.show();
}
示例15: onCreateDialog
import android.view.ContextThemeWrapper; //導入依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
ContextThemeWrapper wrapper = new ContextThemeWrapper(getContext(), android.R.style.Theme_Material_Light);
@SuppressLint("InflateParams") // This View will have it's params ignored anyway:
final View view = LayoutInflater.from(wrapper).inflate(R.layout.fragment_open_with, null);
final Dialog dialog = new CustomWidthBottomSheetDialog(wrapper);
dialog.setContentView(view);
final RecyclerView appList = view.findViewById(R.id.apps);
appList.setLayoutManager(new LinearLayoutManager(wrapper, LinearLayoutManager.VERTICAL, false));
AppAdapter adapter = new AppAdapter(
wrapper,
(ActivityInfo[]) getArguments().getParcelableArray(ARGUMENT_KEY_APPS),
(ActivityInfo) getArguments().getParcelable(ARGUMENT_STORE));
adapter.setOnAppSelectedListener(this);
appList.setAdapter(adapter);
return dialog;
}