gt:                                 new DialogInterface.OnClickListener() {
context: package me.ccrama.redditslide.Activities;
  
  import android.content.ActivityNotFoundException;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.content.res.Configuration;
  import android.graphics.PorterDuff;
  import android.net.Uri;
  import android.os.AsyncTask;
  import android.os.Build;
  import android.os.Bundle;
  import android.support.annotation.NonNull;
  import android.support.design.widget.TabLayout;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentStatePagerAdapter;
  import android.support.v4.view.ViewPager;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.PopupMenu;
  import android.text.Spannable;
  import android.util.Log;
  import android.view.Gravity;
  import android.view.KeyEvent;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.Window;
  import android.view.animation.LinearInterpolator;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  
  import com.afollestad.materialdialogs.AlertDialogWrapper;
  import com.afollestad.materialdialogs.DialogAction;
  import com.afollestad.materialdialogs.MaterialDialog;
  
  import net.dean.jraw.models.MultiReddit;
  import net.dean.jraw.models.MultiSubreddit;
  import net.dean.jraw.models.Submission;
  import net.dean.jraw.paginators.Sorting;
  import net.dean.jraw.paginators.TimePeriod;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import me.ccrama.redditslide.Authentication;
  import me.ccrama.redditslide.ColorPreferences;
  import me.ccrama.redditslide.Fragments.MultiredditView;
  import me.ccrama.redditslide.R;
  import me.ccrama.redditslide.Reddit;
  import me.ccrama.redditslide.SettingValues;
  import me.ccrama.redditslide.UserSubscriptions;
  import me.ccrama.redditslide.Views.CatchStaggeredGridLayoutManager;
  import me.ccrama.redditslide.Views.PreCachingLayoutManager;
  import me.ccrama.redditslide.Visuals.Palette;
  import me.ccrama.redditslide.util.LogUtil;
  
  /**
   * Created by ccrama on 9/17/2015.
   */
  public class MultiredditOverview extends BaseActivityAnim {
  
      public static final String EXTRA_PROFILE = "profile";
  
      public static MultiReddit          searchMulti;
      public        OverviewPagerAdapter adapter;
      private       ViewPager            pager;
      private       String               profile;
      private       TabLayout            tabs;
      private       List<MultiReddit>    usedArray;
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          MenuInflater inflater = getMenuInflater();
          inflater.inflate(R.menu.menu_multireddits, menu);
  
          if (!profile.isEmpty()) {
              menu.findItem(R.id.action_edit).setVisible(false);
              menu.findItem(R.id.create).setVisible(false);
          }
  
          //   if (mShowInfoButton) menu.findItem(R.id.action_info).setVisible(true);
          //   else menu.findItem(R.id.action_info).setVisible(false);
  
          return true;
      }
  
      @Override
      public boolean dispatchKeyEvent(KeyEvent event) {
          /* removed for now
          int keyCode = event.getKeyCode();
          switch (keyCode) {
              case KeyEvent.KEYCODE_VOLUME_UP:
                  return ((MultiredditView) adapter.getCurrentFragment()).onKeyDown(keyCode);
              case KeyEvent.KEYCODE_VOLUME_DOWN:
                  return ((MultiredditView) adapter.getCurrentFragment()).onKeyDown(keyCode);
              default:
                  return super.dispatchKeyEvent(event);
          }*/
          return super.dispatchKeyEvent(event);
      }
  
      public int getCurrentPage() {
          int position = 0;
          int currentOrientation = getResources().getConfiguration().orientation;
          if (((MultiredditView) adapter.getCurrentFragment()).rv.getLayoutManager() instanceof LinearLayoutManager
                  && currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
              position =
                      ((LinearLayoutManager) ((MultiredditView) adapter.getCurrentFragment()).rv.getLayoutManager())
                              .findFirstVisibleItemPosition() - 1;
          } else if (((MultiredditView) adapter.getCurrentFragment()).rv.getLayoutManager() instanceof CatchStaggeredGridLayoutManager) {
              int[] firstVisibleItems = null;
              firstVisibleItems =
                      ((CatchStaggeredGridLayoutManager) ((MultiredditView) adapter.getCurrentFragment()).rv
                              .getLayoutManager()).findFirstVisibleItemPositions(firstVisibleItems);
              if (firstVisibleItems != null && firstVisibleItems.length > 0) {
                  position = firstVisibleItems[0] - 1;
              }
          } else {
              position =
                      ((PreCachingLayoutManager) ((MultiredditView) adapter.getCurrentFragment()).rv.getLayoutManager())
                              .findFirstVisibleItemPosition() - 1;
          }
          return position;
      }
  
      String term;
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
  
              case android.R.id.home:
                  try {
                      onBackPressed();
                  } catch (Exception ignored) {
  
                  }
                  return true;
              case R.id.action_edit: {
                  if (profile.isEmpty()
                          && (UserSubscriptions.multireddits != null)
                          && !UserSubscriptions.multireddits.isEmpty()) {
                      Intent i = new Intent(MultiredditOverview.this, CreateMulti.class);
                      i.putExtra(CreateMulti.EXTRA_MULTI, UserSubscriptions.getMultireddits()
                              .get(pager.getCurrentItem())
                              .getDisplayName());
                      startActivity(i);
                  }
              }
              return true;
              case R.id.search: {
                  List<MultiReddit> multireddits = getMultireddits();
                  if ((multireddits != null) && !multireddits.isEmpty()) {
                      searchMulti = multireddits.get(pager.getCurrentItem());
                      MaterialDialog.Builder builder =
                              new MaterialDialog.Builder(this).title(R.string.search_title)
                                      .alwaysCallInputCallback()
                                      .input(getString(R.string.search_msg), "",
                                              new MaterialDialog.InputCallback() {
                                                  @Override
                                                  public void onInput(MaterialDialog materialDialog,
                                                          CharSequence charSequence) {
                                                      term = charSequence.toString();
                                                  }
                                              });
  
                      //Add "search current sub" if it is not frontpage/all/random
                      builder.positiveText(getString(R.string.search_subreddit,
                              "/m/" + searchMulti.getDisplayName()))
                              .onPositive(new MaterialDialog.SingleButtonCallback() {
                                  @Override
                                  public void onClick(@NonNull MaterialDialog materialDialog,
                                          @NonNull DialogAction dialogAction) {
                                      Intent i = new Intent(MultiredditOverview.this, Search.class);
                                      i.putExtra(Search.EXTRA_TERM, term);
                                      i.putExtra(Search.EXTRA_MULTIREDDIT,
                                              searchMulti.getDisplayName());
                                      startActivity(i);
                                  }
                              });
  
                      builder.show();
                  }
              }
              return true;
              case R.id.create:
                  if (profile.isEmpty()) {
                      Intent i2 = new Intent(MultiredditOverview.this, CreateMulti.class);
                      startActivity(i2);
                  }
                  return true;
              case R.id.action_sort:
                  openPopup();
                  return true;
  
              case R.id.subs:
                  ((DrawerLayout) findViewById(R.id.drawer_layout)).openDrawer(Gravity.RIGHT);
                  return true;
              case R.id.gallery:
                  if (SettingValues.tabletUI) {
                      List<Submission> posts =
                              ((MultiredditView) adapter.getCurrentFragment()).posts.posts;
                      if (posts != null && !posts.isEmpty()) {
                          Intent i2 = new Intent(this, Gallery.class);
                          i2.putExtra(Gallery.EXTRA_PROFILE, profile);
                          i2.putExtra(Gallery.EXTRA_MULTIREDDIT,
                                  ((MultiredditView) adapter.getCurrentFragment()).posts.multiReddit.getDisplayName());
                          startActivity(i2);
                      }
                  } else {
                      AlertDialogWrapper.Builder b = new AlertDialogWrapper.Builder(this).setTitle(
                              R.string.general_gallerymode_ispro)
                              .setMessage(R.string.pro_upgrade_msg)
                              .setPositiveButton(R.string.btn_yes_exclaim,
                                      new DialogInterface.OnClickListener() {
                                          public void onClick(DialogInterface dialog,
                                                  int whichButton) {
                                              try {
                                                  startActivity(new Intent(Intent.ACTION_VIEW,
                                                          Uri.parse(
                                                                  "market://details?id=me.ccrama.slideforreddittabletuiunlock")));
                                              } catch (ActivityNotFoundException e) {
                                                  startActivity(new Intent(Intent.ACTION_VIEW,
                                                          Uri.parse(
                                                                  "http://play.google.com/store/apps/details?id=me.ccrama.slideforreddittabletuiunlock")));
                                              }
                                          }
                                      })
                              .setNegativeButton(R.string.btn_no_danks,
                                      new DialogInterface.OnClickListener() {
                                          public void onClick(DialogInterface dialog,
                                                  int whichButton) {
                                              dialog.dismiss();
                                          }
                                      });
                      if (SettingValues.previews > 0) {
                          b.setNeutralButton(getString(R.string.pro_previews, SettingValues.previews),
                                  new DialogInterface.OnClickListener() {
                                      @Override
                                      public void onClick(DialogInterface dialog, int which) {
                                          SettingValues.prefs.edit()
                                                  .putInt(SettingValues.PREVIEWS_LEFT,
                                                          SettingValues.previews - 1)
                                                  .apply();
                                          SettingValues.previews = SettingValues.prefs.getInt(
                                                  SettingValues.PREVIEWS_LEFT, 10);
                                          List<Submission> posts =
                                                  ((MultiredditView) adapter.getCurrentFragment()).posts.posts;
                                          if (posts != null && !posts.isEmpty()) {
                                              Intent i2 = new Intent(MultiredditOverview.this,
                                                      Gallery.class);
                                              i2.putExtra(Gallery.EXTRA_PROFILE, profile);
                                              i2.putExtra(Gallery.EXTRA_MULTIREDDIT,
                                                      ((MultiredditView) adapter.getCurrentFragment()).posts.multiReddit
                                                              .getDisplayName());
                                              startActivity(i2);
                                          }
                                      }
                                  });
                      }
                      b.show();
                  }
                  return true;
              case R.id.action_shadowbox:
                  if (SettingValues.tabletUI) {
                      List<Submission> posts =
                              ((MultiredditView) adapter.getCurrentFragment()).posts.posts;
                      if (posts != null && !posts.isEmpty()) {
                          Intent i = new Intent(this, Shadowbox.class);
                          i.putExtra(Shadowbox.EXTRA_PAGE, getCurrentPage());
                          i.putExtra(Shadowbox.EXTRA_PROFILE, profile);
                          i.putExtra(Shadowbox.EXTRA_MULTIREDDIT,
                                  ((MultiredditView) adapter.getCurrentFragment()).posts.multiReddit.getDisplayName());
                          startActivity(i);
                      }
                  } else {
                      AlertDialogWrapper.Builder b = new AlertDialogWrapper.Builder(this).setTitle(
                              R.string.general_shadowbox_ispro)
                              .setMessage(R.string.pro_upgrade_msg)
                              .setPositiveButton(R.string.btn_yes_exclaim,
                                              new DialogInterface.OnClickListener() {
                                                  public void onClick(DialogInterface dialog,
                                                          int whichButton) {
                                                      try {
                                                          startActivity(new Intent(Intent.ACTION_VIEW,
                                                                  Uri.parse(
                                                                          "market://details?id=me.ccrama.slideforreddittabletuiunlock")));
                                                      } catch (ActivityNotFoundException e) {
                                                          startActivity(new Intent(Intent.ACTION_VIEW,
                                                                  Uri.parse(
                                                                          "http://play.google.com/store/apps/details?id=me.ccrama.slideforreddittabletuiunlock")));
                                                      }
                                                  }
                                              })
                                      .setNegativeButton(R.string.btn_no_danks,
                                              new DialogInterface.OnClickListener() {
                                                  public void onClick(DialogInterface dialog,
                                                          int whichButton) {
                                                      dialog.dismiss();
                                                  }
                                              });
                      if (SettingValues.previews > 0
                              && adapter != null
                              && ((MultiredditView) adapter.getCurrentFragment()).posts != null
                              && ((MultiredditView) adapter.getCurrentFragment()).posts.posts != null
                              && !((MultiredditView) adapter.getCurrentFragment()).posts.posts.isEmpty()) {
                          b.setNeutralButton(getString(R.string.pro_previews, SettingValues.previews),
                                  new DialogInterface.OnClickListener() {
                                      @Override
                                      public void onClick(DialogInterface dialog, int which) {
                                          SettingValues.prefs.edit()
                                                  .putInt(SettingValues.PREVIEWS_LEFT,
                                                          SettingValues.previews - 1)
                                                  .apply();
                                          SettingValues.previews = SettingValues.prefs.getInt(
                                                  SettingValues.PREVIEWS_LEFT, 10);
                                          List<Submission> posts =
                                                  ((MultiredditView) adapter.getCurrentFragment()).posts.posts;
                                          if (posts != null && !posts.isEmpty()) {
                                              Intent i = new Intent(MultiredditOverview.this,
                                                      Shadowbox.class);
                                              i.putExtra(Shadowbox.EXTRA_PAGE, getCurrentPage());
                                              i.putExtra(Shadowbox.EXTRA_PROFILE, profile);
                                              i.putExtra(Shadowbox.EXTRA_MULTIREDDIT,
                                                      ((MultiredditView) adapter.getCurrentFragment()).posts.multiReddit
                                                              .getDisplayName());
                                              startActivity(i);
                                          }
                                      }
                                  });
                      }
                      b.show();
                  }
                  return true;
              default:
                  return false;
          }
      }
  
      private void buildDialog() {
          buildDialog(false);
      }
  
      private void buildDialog(boolean wasException) {
          try {
              AlertDialogWrapper.Builder b =
                      new AlertDialogWrapper.Builder(MultiredditOverview.this).setCancelable(false)
                              .setOnDismissListener(new DialogInterface.OnDismissListener() {
                                  @Override
                                  public void onDismiss(DialogInterface dialog) {
                                      finish();
                                  }
                              });
              if (wasException) {
                  b.setTitle(R.string.err_title)
                          .setMessage(R.string.err_loading_content)
                          .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                                  finish();
                              }
                          });
              } else if (profile.isEmpty()) {
                  b.setTitle(R.string.multireddit_err_title)
                          .setMessage(R.string.multireddit_err_msg)
                          .setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                                  Intent i = new Intent(MultiredditOverview.this, CreateMulti.class);
                                  startActivity(i);
                              }
                          })
                          .setNegativeButton(R.string.btn_no, new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                                  finish();
                              }
                          });
              } else {
                  b.setTitle(R.string.public_multireddit_err_title)
                          .setMessage(R.string.public_multireddit_err_msg)
                          .setNegativeButton(R.string.btn_go_back,
  