Program: 14425
Project: 14425
Buggy source:
public PostsListAdapter getPostListAdapter(){
  if (mPostsListAdapter == null) {
    PostsListAdapter.OnLoadMoreListener loadMoreListener=new PostsListAdapter.OnLoadMoreListener(){
      @Override public void onLoadMore(){
        if (mCanLoadMorePosts && !mIsFetchingPosts)         requestPosts(true);
      }
    }
;
    PostsListAdapter.OnPostsLoadedListener postsLoadedListener=new PostsListAdapter.OnPostsLoadedListener(){
      @Override public void onPostsLoaded(      int postCount){
        if (!isAdded()) {
          return;
        }
        if (getListView().getEmptyView() == null) {
          getListView().setEmptyView(getView().findViewById(R.id.empty_view));
        }
        if (postCount == 0 && !isRefreshing()) {
          updateEmptyView(MessageType.NO_CONTENT);
        }
        if (postCount == 0 && mCanLoadMorePosts) {
          if (isAdded() && NetworkUtils.isNetworkAvailable(getActivity())) {
            setRefreshing(true);
            requestPosts(false);
          }
 else {
            updateEmptyView(MessageType.NETWORK_ERROR);
          }
        }
 else         if (mShouldSelectFirstPost) {
          mShouldSelectFirstPost=false;
          if (mPostsListAdapter.getCount() > 0) {
            PostsListPost postsListPost=(PostsListPost)mPostsListAdapter.getItem(0);
            if (postsListPost != null) {
              showPost(postsListPost.getPostId());
              getListView().setItemChecked(0,true);
            }
          }
        }
 else         if (isAdded() && ((PostsActivity)getActivity()).isDualPane()) {
          int selectedPosition=getListView().getCheckedItemPosition();
          if (selectedPosition != ListView.INVALID_POSITION && selectedPosition < mPostsListAdapter.getCount()) {
            PostsListPost postsListPost=(PostsListPost)mPostsListAdapter.getItem(selectedPosition);
            if (postsListPost != null) {
              showPost(postsListPost.getPostId());
            }
          }
        }
      }
    }
;
    mPostsListAdapter=new PostsListAdapter(getActivity(),mIsPage,loadMoreListener,postsLoadedListener);
  }
  return mPostsListAdapter;
}

Fixed version (ground truth):
public PostsListAdapter getPostListAdapter(){
  if (mPostsListAdapter == null) {
    PostsListAdapter.OnLoadMoreListener loadMoreListener=new PostsListAdapter.OnLoadMoreListener(){
      @Override public void onLoadMore(){
        if (mCanLoadMorePosts && !mIsFetchingPosts)         requestPosts(true);
      }
    }
;
    PostsListAdapter.OnPostsLoadedListener postsLoadedListener=new PostsListAdapter.OnPostsLoadedListener(){
      @Override public void onPostsLoaded(      int postCount){
        if (!isAdded()) {
          return;
        }
        if (postCount == 0) {
          mEmptyView.setVisibility(View.VISIBLE);
        }
 else {
          mEmptyView.setVisibility(View.GONE);
        }
        if (!isRefreshing()) {
          updateEmptyView(MessageType.NO_CONTENT);
        }
        if (postCount == 0 && mCanLoadMorePosts) {
          if (isAdded() && NetworkUtils.isNetworkAvailable(getActivity())) {
            setRefreshing(true);
            requestPosts(false);
          }
 else {
            updateEmptyView(MessageType.NETWORK_ERROR);
          }
        }
 else         if (mShouldSelectFirstPost) {
          mShouldSelectFirstPost=false;
          if (mPostsListAdapter.getCount() > 0) {
            PostsListPost postsListPost=(PostsListPost)mPostsListAdapter.getItem(0);
            if (postsListPost != null) {
              showPost(postsListPost.getPostId());
              getListView().setItemChecked(0,true);
            }
          }
        }
 else         if (isAdded() && ((PostsActivity)getActivity()).isDualPane()) {
          int selectedPosition=getListView().getCheckedItemPosition();
          if (selectedPosition != ListView.INVALID_POSITION && selectedPosition < mPostsListAdapter.getCount()) {
            PostsListPost postsListPost=(PostsListPost)mPostsListAdapter.getItem(selectedPosition);
            if (postsListPost != null) {
              showPost(postsListPost.getPostId());
            }
          }
        }
      }
    }
;
    mPostsListAdapter=new PostsListAdapter(getActivity(),mIsPage,loadMoreListener,postsLoadedListener);
  }
  return mPostsListAdapter;
}