Program: 14664
Project: 14664
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  final Context context=container.getContext();
  final ViewGroup view=(ViewGroup)inflater.inflate(R.layout.reader_fragment_post_list,container,false);
  boolean hasTransparentActionBar=isFullScreenSupported();
  mActionBarHeight=DisplayUtils.getActionBarHeight(context);
  mListView=(WPListView)view.findViewById(android.R.id.list);
  mNewPostsBar=(TextView)view.findViewById(R.id.text_new_posts);
  mNewPostsBar.setVisibility(View.GONE);
  mNewPostsBar.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      reloadPosts(true);
      hideNewPostsBar();
    }
  }
);
  if (hasTransparentActionBar) {
    ReaderUtils.setTopMargin(mNewPostsBar,mActionBarHeight);
  }
switch (getPostListType()) {
case TAG_FOLLOWED:
    if (hasTransparentActionBar) {
      ReaderUtils.addListViewHeader(mListView,mActionBarHeight);
    }
  break;
case TAG_PREVIEW:
final ViewGroup previewContainer=(ViewGroup)view.findViewById(R.id.layout_preview_container);
if (hasTransparentActionBar) {
ReaderUtils.setTopMargin(previewContainer,mActionBarHeight);
}
mTagInfoView=(ViewGroup)inflater.inflate(R.layout.reader_tag_preview_header,container,false);
previewContainer.addView(mTagInfoView);
previewContainer.setVisibility(View.VISIBLE);
break;
case BLOG_PREVIEW:
mBlogInfoView=new ReaderBlogInfoHeader(context);
if (hasTransparentActionBar) {
ReaderUtils.setTopMargin(mBlogInfoView,mActionBarHeight);
}
view.addView(mBlogInfoView);
mBlogInfoView.bringToFront();
mListView.setHeaderDividersEnabled(false);
mMshotSpacerView=ReaderUtils.addListViewHeader(mListView,mBlogInfoView.getMshotDefaultHeight());
mBlogInfoView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener(){
@Override public void onGlobalLayout(){
mBlogInfoView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
mMshotSpacerView.getLayoutParams().height=mBlogInfoView.getMshotDefaultHeight() + mBlogInfoView.getInfoContainerHeight();
repositionBlogInfoView();
}
}
);
mListView.setOnScrollChangedListener(this);
break;
}
mEmptyView=view.findViewById(R.id.empty_view);
mListView.setOnScrollListener(this);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
@Override public void onItemClick(AdapterView<?> adapterView,View view,int position,long id){
position-=mListView.getHeaderViewsCount();
if (position >= 0 && mPostSelectedListener != null) {
ReaderPost post=(ReaderPost)getPostAdapter().getItem(position);
if (post != null) {
mPostSelectedListener.onPostSelected(post.blogId,post.postId);
}
}
}
}
);
mProgress=(ProgressBar)view.findViewById(R.id.progress_footer);
mProgress.setVisibility(View.GONE);
mPullToRefreshHelper=new PullToRefreshHelper(getActivity(),(PullToRefreshLayout)view.findViewById(R.id.ptr_layout),new RefreshListener(){
@Override public void onRefreshStarted(View view){
if (getActivity() == null || !NetworkUtils.checkConnection(getActivity())) {
mPullToRefreshHelper.setRefreshing(false);
return;
}
switch (getPostListType()) {
case TAG_FOLLOWED:
case TAG_PREVIEW:
updatePostsWithTag(getCurrentTag(),RequestDataAction.LOAD_NEWER,RefreshType.MANUAL);
break;
case BLOG_PREVIEW:
updatePostsInCurrentBlog(RequestDataAction.LOAD_NEWER);
break;
}
}
}
);
return view;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  final Context context=container.getContext();
  final ViewGroup view=(ViewGroup)inflater.inflate(R.layout.reader_fragment_post_list,container,false);
  boolean hasTransparentActionBar=isFullScreenSupported();
  mActionBarHeight=DisplayUtils.getActionBarHeight(context);
  mListView=(WPListView)view.findViewById(android.R.id.list);
  mNewPostsBar=(TextView)view.findViewById(R.id.text_new_posts);
  mNewPostsBar.setVisibility(View.GONE);
  mNewPostsBar.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      reloadPosts(true);
      hideNewPostsBar();
    }
  }
);
  if (hasTransparentActionBar) {
    ReaderUtils.setTopMargin(mNewPostsBar,mActionBarHeight);
  }
switch (getPostListType()) {
case TAG_FOLLOWED:
    if (hasTransparentActionBar) {
      ReaderUtils.addListViewHeader(mListView,mActionBarHeight);
    }
  break;
case TAG_PREVIEW:
final ViewGroup previewContainer=(ViewGroup)view.findViewById(R.id.layout_preview_container);
if (hasTransparentActionBar) {
ReaderUtils.setTopMargin(previewContainer,mActionBarHeight);
}
mTagInfoView=(ViewGroup)inflater.inflate(R.layout.reader_tag_preview_header,container,false);
previewContainer.addView(mTagInfoView);
previewContainer.setVisibility(View.VISIBLE);
break;
case BLOG_PREVIEW:
mBlogInfoView=new ReaderBlogInfoHeader(context);
if (hasTransparentActionBar) {
ReaderUtils.setTopMargin(mBlogInfoView,mActionBarHeight);
}
view.addView(mBlogInfoView);
mListView.setHeaderDividersEnabled(false);
mMshotSpacerView=ReaderUtils.addListViewHeader(mListView,mBlogInfoView.getMshotDefaultHeight());
mBlogInfoView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener(){
@Override public void onGlobalLayout(){
mBlogInfoView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
mMshotSpacerView.getLayoutParams().height=mBlogInfoView.getMshotDefaultHeight() + mBlogInfoView.getInfoContainerHeight();
}
}
);
mBlogInfoView.bringToFront();
mListView.setOnScrollChangedListener(this);
break;
}
mEmptyView=view.findViewById(R.id.empty_view);
mListView.setOnScrollListener(this);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
@Override public void onItemClick(AdapterView<?> adapterView,View view,int position,long id){
position-=mListView.getHeaderViewsCount();
if (position >= 0 && mPostSelectedListener != null) {
ReaderPost post=(ReaderPost)getPostAdapter().getItem(position);
if (post != null) {
mPostSelectedListener.onPostSelected(post.blogId,post.postId);
}
}
}
}
);
mProgress=(ProgressBar)view.findViewById(R.id.progress_footer);
mProgress.setVisibility(View.GONE);
mPullToRefreshHelper=new PullToRefreshHelper(getActivity(),(PullToRefreshLayout)view.findViewById(R.id.ptr_layout),new RefreshListener(){
@Override public void onRefreshStarted(View view){
if (getActivity() == null || !NetworkUtils.checkConnection(getActivity())) {
mPullToRefreshHelper.setRefreshing(false);
return;
}
switch (getPostListType()) {
case TAG_FOLLOWED:
case TAG_PREVIEW:
updatePostsWithTag(getCurrentTag(),RequestDataAction.LOAD_NEWER,RefreshType.MANUAL);
break;
case BLOG_PREVIEW:
updatePostsInCurrentBlog(RequestDataAction.LOAD_NEWER);
break;
}
}
}
);
return view;
}