Search in sources :

Example 21 with ContextThemeWrapper

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;
}
Also used : Context(android.content.Context) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) LayoutInflater(android.view.LayoutInflater) ArrayList(java.util.ArrayList) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) HorizontalScrollView(android.widget.HorizontalScrollView) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

ContextThemeWrapper (androidx.appcompat.view.ContextThemeWrapper)21 Context (android.content.Context)14 View (android.view.View)12 ColorPreferences (me.ccrama.redditslide.Visuals.ColorPreferences)10 TextView (android.widget.TextView)9 LayoutInflater (android.view.LayoutInflater)7 Intent (android.content.Intent)6 ImageView (android.widget.ImageView)6 ArrayList (java.util.ArrayList)6 DialogInterface (android.content.DialogInterface)5 AlertDialog (androidx.appcompat.app.AlertDialog)5 RecyclerView (androidx.recyclerview.widget.RecyclerView)5 Snackbar (com.google.android.material.snackbar.Snackbar)5 SpoilerRobotoTextView (me.ccrama.redditslide.SpoilerRobotoTextView)5 Activity (android.app.Activity)4 ContextWrapper (android.content.ContextWrapper)4 TypedArray (android.content.res.TypedArray)4 HorizontalScrollView (android.widget.HorizontalScrollView)4 NonNull (androidx.annotation.NonNull)4 DialogAction (com.afollestad.materialdialogs.DialogAction)4