public void onItemClick(AdapterView<?> aParent, View aView, int aPosition, long aId) {
          ForumArrayAdapter adapter = (ForumArrayAdapter) mThreadList.getAdapter();

          switch (adapter.getItemType(aPosition)) {
            case THREAD:
              AwfulThread thread = (AwfulThread) adapter.getItem(aPosition);
              Intent viewThread =
                  new Intent().setClass(ForumDisplayActivity.this, ThreadDisplayActivity.class);
              viewThread.putExtra(Constants.THREAD, thread);
              startActivity(viewThread);
              break;

            case SUB_FORUM:
              AwfulForum forum = (AwfulForum) adapter.getItem(aPosition);
              Intent viewForum =
                  new Intent().setClass(ForumDisplayActivity.this, ForumDisplayActivity.class);
              viewForum.putExtra(Constants.FORUM, forum);
              startActivity(viewForum);
              break;
          }
        }
  @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);
  }
 @Override
 public Object onRetainNonConfigurationInstance() {
   return mThreadAdapter.getThreads();
 }