use of androidx.appcompat.view.ContextThemeWrapper in project Slide by ccrama.
the class SubredditView method onPrepareOptionsMenu.
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
// Hide the "Submit" menu item if the currently viewed sub is the frontpage or /r/all.
if (subreddit.equals("frontpage") || subreddit.equals("all") || subreddit.equals("popular") || subreddit.equals("friends") || subreddit.equals("mod")) {
menu.findItem(R.id.submit).setVisible(false);
menu.findItem(R.id.sidebar).setVisible(false);
}
mToolbar.getMenu().findItem(R.id.theme).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
int style = new ColorPreferences(SubredditView.this).getThemeSubreddit(subreddit);
final Context contextThemeWrapper = new ContextThemeWrapper(SubredditView.this, style);
LayoutInflater localInflater = getLayoutInflater().cloneInContext(contextThemeWrapper);
final View dialoglayout = localInflater.inflate(R.layout.colorsub, null);
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add(subreddit);
SettingsSubAdapter.showSubThemeEditor(arrayList, SubredditView.this, dialoglayout);
return false;
}
});
return true;
}
Aggregations