@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.forum_display);

    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mThreadAdapter = new ForumArrayAdapter(this);

    mThreadList = (ListView) findViewById(R.id.forum_list);
    mTitle = (TextView) findViewById(R.id.title);
    mUserCp = (ImageButton) findViewById(R.id.user_cp);
    mNext = (ImageButton) findViewById(R.id.next_page);

    mThreadList.setOnScrollListener(new EndlessScrollListener());
    mThreadList.setAdapter(mThreadAdapter);
    mThreadList.setOnItemClickListener(onThreadSelected);

    mForum = (AwfulSubforum) getIntent().getParcelableExtra(Constants.FORUM);
    if (mForum == null) {
      // This is normally a failure condition, except if we're receiving an
      // intent from an outside link (say, ChromeToPhone). Let's check to see
      // if we have a URL from such a link.
      if (getIntent().getData() != null && getIntent().getData().getScheme().equals("http")) {
        mForum = new AwfulSubforum();
        mForum.setForumId(getIntent().getData().getQueryParameter("forumid"));
      } else {
        // no dice
        Log.e(TAG, "Cannot display null forum");
        finish();
      }
    }

    final ArrayList<AwfulThread> retainedThreadList =
        (ArrayList<AwfulThread>) getLastNonConfigurationInstance();

    if (retainedThreadList == null || retainedThreadList.size() == 0) {
      mFetchTask = new FetchThreadsTask();
      mFetchTask.execute(mForum.getForumId());
    } else {
      mThreadAdapter.setThreads(retainedThreadList);
    }

    // We might not be able to set this here if we're getting it from
    // a link and not a ForumsIndexActivity
    if (mForum.getTitle() != null) {
      mTitle.setText(Html.fromHtml(mForum.getTitle()));
    }

    mUserCp.setOnClickListener(onButtonClick);
    mNext.setOnClickListener(onButtonClick);
  }
 public void onClick(View aView) {
   switch (aView.getId()) {
     case R.id.user_cp:
       startActivity(new Intent().setClass(ForumDisplayActivity.this, UserCPActivity.class));
       break;
     case R.id.next_page:
       if (mForum.getCurrentPage() != mForum.getLastPage()) {
         mForum.setCurrentPage(mForum.getCurrentPage() + 1);
         mFetchTask = new FetchThreadsTask(mForum.getCurrentPage());
         mFetchTask.execute(mForum.getForumId());
       }
       break;
   }
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.settings:
       startActivity(new Intent().setClass(this, SettingsActivity.class));
       return true;
     case R.id.logout:
       NetworkUtils.clearLoginCookies(this);
       startActivityForResult(new Intent().setClass(this, AwfulLoginActivity.class), 0);
       return true;
     case R.id.refresh:
       mFetchTask = new FetchThreadsTask();
       mFetchTask.execute(mForum.getForumId());
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }