use of android.view.ContextThemeWrapper in project AndroidTraining by mixi-inc.
the class ActionBarImpl method getThemedContext.
public Context getThemedContext() {
if (mThemedContext == null) {
TypedValue outValue = new TypedValue();
Resources.Theme currentTheme = mContext.getTheme();
currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
final int targetThemeRes = outValue.resourceId;
if (targetThemeRes != 0) {
//XXX && mContext.getThemeResId() != targetThemeRes) {
mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes);
} else {
mThemedContext = mContext;
}
}
return mThemedContext;
}
use of android.view.ContextThemeWrapper in project AndroidTraining by mixi-inc.
the class ActionBarSherlockCompat method initializePanelMenu.
private boolean initializePanelMenu() {
//getContext();
Context context = mActivity;
// If we have an action bar, initialize the menu with a context themed for it.
if (wActionBar != null) {
TypedValue outValue = new TypedValue();
Resources.Theme currentTheme = context.getTheme();
currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
final int targetThemeRes = outValue.resourceId;
if (targetThemeRes != 0) /*&& context.getThemeResId() != targetThemeRes*/
{
context = new ContextThemeWrapper(context, targetThemeRes);
}
}
mMenu = new MenuBuilder(context);
mMenu.setCallback(this);
return true;
}
use of android.view.ContextThemeWrapper in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class KeyboardLayoutSetTestsBase method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
final Context context = getContext();
final Resources res = context.getResources();
RichInputMethodManager.init(context);
mRichImm = RichInputMethodManager.getInstance();
// Save and reset additional subtypes preference.
mSavedAdditionalSubtypes = mRichImm.getAdditionalSubtypes();
final InputMethodSubtype[] predefinedAdditionalSubtypes = AdditionalSubtypeUtils.createAdditionalSubtypesArray(AdditionalSubtypeUtils.createPrefSubtypes(res.getStringArray(R.array.predefined_subtypes)));
mRichImm.setAdditionalInputMethodSubtypes(predefinedAdditionalSubtypes);
final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById(getKeyboardThemeForTests(), KeyboardTheme.KEYBOARD_THEMES);
setContext(new ContextThemeWrapper(getContext(), keyboardTheme.mStyleId));
KeyboardLayoutSet.onKeyboardThemeChanged();
mScreenMetrics = Settings.readScreenMetrics(res);
final InputMethodInfo imi = mRichImm.getInputMethodInfoOfThisIme();
final int subtypeCount = imi.getSubtypeCount();
for (int index = 0; index < subtypeCount; index++) {
mAllSubtypesList.add(imi.getSubtypeAt(index));
}
}
use of android.view.ContextThemeWrapper in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class KeyboardSwitcher method updateKeyboardThemeAndContextThemeWrapper.
private boolean updateKeyboardThemeAndContextThemeWrapper(final Context context, final KeyboardTheme keyboardTheme) {
if (mThemeContext == null || !keyboardTheme.equals(mKeyboardTheme)) {
mKeyboardTheme = keyboardTheme;
mThemeContext = new ContextThemeWrapper(context, keyboardTheme.mStyleId);
KeyboardLayoutSet.onKeyboardThemeChanged();
return true;
}
return false;
}
use of android.view.ContextThemeWrapper in project Reader by TheKeeperOfPie.
the class FragmentInbox method onCreateView.
@SuppressWarnings("ResourceType")
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_inbox, container, false);
listener = new ControllerInbox.Listener() {
@Override
public void setPage(Page page) {
spinnerPage.setSelection(adapterInboxPage.getPages().indexOf(page));
}
@Override
public RecyclerView.Adapter getAdapter() {
return adapterInbox;
}
@Override
public void setToolbarTitle(CharSequence title) {
toolbar.setTitle(title);
}
@Override
public void setRefreshing(boolean refreshing) {
swipeRefreshInbox.setRefreshing(refreshing);
}
@Override
public void post(Runnable runnable) {
recyclerInbox.post(runnable);
}
};
layoutCoordinator = (CoordinatorLayout) view.findViewById(R.id.layout_coordinator);
layoutAppBar = (AppBarLayout) view.findViewById(R.id.layout_app_bar);
int styleColorBackground = AppSettings.THEME_DARK.equals(mListener.getThemeBackground()) ? R.style.MenuDark : R.style.MenuLight;
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(new ThemeWrapper(activity, UtilsColor.getThemeForColor(getResources(), themer.getColorPrimary(), mListener)), styleColorBackground);
toolbar = (Toolbar) activity.getLayoutInflater().cloneInContext(contextThemeWrapper).inflate(R.layout.toolbar, layoutAppBar, false);
layoutAppBar.addView(toolbar);
((AppBarLayout.LayoutParams) toolbar.getLayoutParams()).setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
toolbar.setTitleTextColor(themer.getColorFilterPrimary().getColor());
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
toolbar.getNavigationIcon().mutate().setColorFilter(themer.getColorFilterPrimary());
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.openDrawer();
}
});
setUpOptionsMenu();
floatingActionButtonNewMessage = (FloatingActionButton) view.findViewById(R.id.fab_new_message);
floatingActionButtonNewMessage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentNewMessage fragmentNewMessage = FragmentNewMessage.newInstance();
getFragmentManager().beginTransaction().hide(FragmentInbox.this).add(R.id.frame_fragment, fragmentNewMessage, FragmentNewMessage.TAG).addToBackStack(null).commit();
}
});
floatingActionButtonNewMessage.setColorFilter(themer.getColorFilterAccent());
behaviorFloatingActionButton = new ScrollAwareFloatingActionButtonBehavior(activity, null, new ScrollAwareFloatingActionButtonBehavior.OnVisibilityChangeListener() {
@Override
public void onStartHideFromScroll() {
}
@Override
public void onEndHideFromScroll() {
}
});
((CoordinatorLayout.LayoutParams) floatingActionButtonNewMessage.getLayoutParams()).setBehavior(behaviorFloatingActionButton);
adapterInboxPage = new AdapterInboxPage(activity);
spinnerPage = new AppCompatSpinner(contextThemeWrapper);
toolbar.addView(spinnerPage);
((Toolbar.LayoutParams) spinnerPage.getLayoutParams()).setMarginEnd((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()));
spinnerPage.setAdapter(adapterInboxPage);
spinnerPage.setSelection(adapterInboxPage.getPages().indexOf(controllerInbox.getPage()));
spinnerPage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
controllerInbox.setPage(adapterInboxPage.getItem(position));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
swipeRefreshInbox = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_inbox);
swipeRefreshInbox.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
controllerInbox.reload();
}
});
linearLayoutManager = new LinearLayoutManager(activity);
recyclerInbox = (RecyclerView) view.findViewById(R.id.recycler_inbox);
recyclerInbox.setHasFixedSize(true);
recyclerInbox.setItemAnimator(new DefaultItemAnimator());
recyclerInbox.getItemAnimator().setRemoveDuration(UtilsAnimation.EXPAND_ACTION_DURATION);
recyclerInbox.setLayoutManager(linearLayoutManager);
recyclerInbox.addItemDecoration(new ItemDecorationDivider(activity, ItemDecorationDivider.VERTICAL_LIST));
AdapterListener adapterListener = new AdapterListener() {
@Override
public void scrollAndCenter(int position, int height) {
linearLayoutManager.scrollToPositionWithOffset(position, 0);
}
@Override
public void hideToolbar() {
AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
}
@Override
public void clearDecoration() {
behaviorFloatingActionButton.animateOut(floatingActionButtonNewMessage);
AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
}
@Override
public void requestMore() {
controllerInbox.loadMore();
}
@Override
public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
recyclerInbox.requestDisallowInterceptTouchEvent(disallow);
swipeRefreshInbox.requestDisallowInterceptTouchEvent(disallow);
}
@Override
public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
}
};
AdapterCommentList.ViewHolderComment.Listener listenerComments = new AdapterCommentList.ViewHolderComment.Listener() {
@Override
public void onToggleComment(Comment comment) {
}
@Override
public void onShowReplyEditor(Comment comment) {
}
@Override
public void onEditComment(Comment comment, String text) {
}
@Override
public void onSendComment(Comment comment, String text) {
}
@Override
public void onMarkRead(Comment comment) {
}
@Override
public void onLoadNestedComments(Comment comment) {
}
@Override
public void onJumpToParent(Comment comment) {
}
@Override
public void onViewProfile(Comment comment) {
}
@Override
public void onCopyText(Comment comment) {
}
@Override
public void onDeleteComment(Comment comment) {
}
@Override
public void onReport(Comment comment) {
}
@Override
public void onVoteComment(Comment comment, AdapterCommentList.ViewHolderComment viewHolderComment, Likes vote) {
}
@Override
public void onSave(Comment comment) {
}
};
if (adapterInbox == null) {
adapterInbox = new AdapterInbox(controllerInbox, controllerUser, adapterListener, listenerComments, mListener.getEventListenerBase());
}
recyclerInbox.setAdapter(adapterInbox);
return view;
}
Aggregations