@Override
  public void onDestroy() {
    super.onDestroy();

    if (mDialog != null) {
      mDialog.dismiss();
    }

    if (mFetchTask != null) {
      mFetchTask.cancel(true);
    }
  }
  @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);
  }