Program: 14573
Project: 14573
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  final ViewGroup rootView=(ViewGroup)inflater.inflate(R.layout.reader_fragment_post_list,container,false);
  mListView=(WPListView)rootView.findViewById(android.R.id.list);
  mNewPostsBar=(TextView)rootView.findViewById(R.id.text_new_posts);
  mNewPostsBar.setVisibility(View.GONE);
  mNewPostsBar.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      reloadPosts();
      hideNewPostsBar();
    }
  }
);
switch (getPostListType()) {
case TAG_FOLLOWED:
    break;
case TAG_PREVIEW:
  mTagInfoView=(ViewGroup)inflater.inflate(R.layout.reader_tag_info_view,container,false);
rootView.addView(mTagInfoView);
ReaderUtils.layoutBelow(rootView,R.id.ptr_layout,mTagInfoView.getId());
break;
case BLOG_PREVIEW:
mBlogInfoView=new ReaderBlogInfoView(container.getContext());
rootView.addView(mBlogInfoView);
mBlogInfoView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT));
int spacerHeight=mBlogInfoView.getMshotHeight() + DisplayUtils.dpToPx(container.getContext(),105);
mMshotSpacerView=ReaderUtils.addListViewHeader(mListView,spacerHeight);
mMshotSpacerView.setTag(MSHOT_SPACER_TAG);
mBlogInfoView.bringToFront();
mBlogInfoView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener(){
@Override public void onGlobalLayout(){
int currentHeight=mMshotSpacerView.getLayoutParams().height;
int newHeight=mBlogInfoView.getInfoContainerHeight() + mBlogInfoView.getMshotHeight();
if (currentHeight != newHeight) {
mMshotSpacerView.getLayoutParams().height=newHeight;
}
}
}
);
break;
}
mEmptyView=rootView.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)rootView.findViewById(R.id.progress_footer);
mProgress.setVisibility(View.GONE);
mPullToRefreshHelper=new PullToRefreshHelper(getActivity(),(PullToRefreshLayout)rootView.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,ReaderTypes.RefreshType.MANUAL);
break;
case BLOG_PREVIEW:
updatePostsInCurrentBlog(RequestDataAction.LOAD_NEWER);
break;
}
}
}
);
return rootView;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  final ViewGroup rootView=(ViewGroup)inflater.inflate(R.layout.reader_fragment_post_list,container,false);
  mListView=(WPListView)rootView.findViewById(android.R.id.list);
  mNewPostsBar=(TextView)rootView.findViewById(R.id.text_new_posts);
  mNewPostsBar.setVisibility(View.GONE);
  mNewPostsBar.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      reloadPosts();
      hideNewPostsBar();
    }
  }
);
switch (getPostListType()) {
case TAG_FOLLOWED:
    break;
case TAG_PREVIEW:
  mTagInfoView=(ViewGroup)inflater.inflate(R.layout.reader_tag_info_view,container,false);
rootView.addView(mTagInfoView);
ReaderUtils.layoutBelow(rootView,R.id.ptr_layout,mTagInfoView.getId());
break;
case BLOG_PREVIEW:
mBlogInfoView=new ReaderBlogInfoView(container.getContext());
rootView.addView(mBlogInfoView);
mBlogInfoView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT));
int spacerHeight=mBlogInfoView.getMshotHeight() + DisplayUtils.dpToPx(container.getContext(),105);
mMshotSpacerView=ReaderUtils.addListViewHeader(mListView,spacerHeight);
mMshotSpacerView.setTag(MSHOT_SPACER_TAG);
mBlogInfoView.bringToFront();
mBlogInfoView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener(){
@Override public void onGlobalLayout(){
int currentHeight=mMshotSpacerView.getLayoutParams().height;
int newHeight=mBlogInfoView.getInfoContainerHeight() + mBlogInfoView.getMshotHeight();
if (currentHeight != newHeight) {
mMshotSpacerView.getLayoutParams().height=newHeight;
}
}
}
);
break;
}
mEmptyView=rootView.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) {
AnalyticsTracker.track(AnalyticsTracker.Stat.READER_OPENED_ARTICLE);
mPostSelectedListener.onPostSelected(post.blogId,post.postId);
}
}
}
}
);
mProgress=(ProgressBar)rootView.findViewById(R.id.progress_footer);
mProgress.setVisibility(View.GONE);
mPullToRefreshHelper=new PullToRefreshHelper(getActivity(),(PullToRefreshLayout)rootView.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,ReaderTypes.RefreshType.MANUAL);
break;
case BLOG_PREVIEW:
updatePostsInCurrentBlog(RequestDataAction.LOAD_NEWER);
break;
}
}
}
);
return rootView;
}