Program: 20450
Project: 20450
Buggy source:
private RelativeLayout createView(){
  RelativeLayout compound=new RelativeLayout(getActivity());
  LinearLayout listViewContainer=new LinearLayout(getActivity());
  listViewContainer.setOrientation(LinearLayout.VERTICAL);
  filterView=new FilterView(getActivity());
  filterView.setVisibility(View.GONE);
  listViewContainer.addView(filterView,Utils.MATCH_WRAP_PARAMS);
  if (viewMode == ThreadManager.ViewMode.LIST) {
    ListView list=new ListView(getActivity());
    listView=list;
    postAdapter=new PostAdapter(getActivity(),threadManager,listView,this);
    listView.setAdapter(postAdapter);
    list.setSelectionFromTop(loadable.listViewIndex,loadable.listViewTop);
  }
 else   if (viewMode == ThreadManager.ViewMode.GRID) {
    GridView grid=new GridView(getActivity());
    grid.setNumColumns(GridView.AUTO_FIT);
    int postGridWidth=baseActivity.getResources().getDimensionPixelSize(R.dimen.post_grid_width);
    grid.setColumnWidth(postGridWidth);
    listView=grid;
    postAdapter=new PostAdapter(getActivity(),threadManager,listView,this);
    listView.setAdapter(postAdapter);
    listView.setSelection(loadable.listViewIndex);
  }
  listView.setOnScrollListener(new OnScrollListener(){
    @Override public void onScrollStateChanged(    AbsListView view,    int scrollState){
      if (!isFiltering) {
        if (skipLogic != null) {
          skipLogic.onScrollStateChanged(view,scrollState);
        }
      }
    }
    @Override public void onScroll(    AbsListView view,    int firstVisibleItem,    int visibleItemCount,    int totalItemCount){
      if (!isFiltering) {
        if (loadable != null) {
          int index=view.getFirstVisiblePosition();
          View v=view.getChildAt(0);
          int top=v == null ? 0 : v.getTop();
          if (index != 0 || top != 0) {
            loadable.listViewIndex=index;
            loadable.listViewTop=top;
          }
        }
        if (skipLogic != null) {
          skipLogic.onScroll(view,firstVisibleItem,visibleItemCount,totalItemCount);
        }
      }
    }
  }
);
  listViewContainer.addView(listView,Utils.MATCH_PARAMS);
  compound.addView(listViewContainer,Utils.MATCH_PARAMS);
  if (loadable.isThreadMode()) {
    skip=new ImageView(getActivity());
    skip.setImageResource(R.drawable.skip_arrow_down);
    skip.setVisibility(View.GONE);
    compound.addView(skip,Utils.WRAP_PARAMS);
    RelativeLayout.LayoutParams params=(RelativeLayout.LayoutParams)skip.getLayoutParams();
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    params.setMargins(0,0,Utils.dp(8),Utils.dp(8));
    skip.setLayoutParams(params);
    skipLogic=new SkipLogic(skip,listView);
  }
  return compound;
}

Fixed version (ground truth):
private RelativeLayout createView(){
  RelativeLayout compound=new RelativeLayout(getActivity());
  LinearLayout listViewContainer=new LinearLayout(getActivity());
  listViewContainer.setOrientation(LinearLayout.VERTICAL);
  filterView=new FilterView(getActivity());
  filterView.setVisibility(View.GONE);
  listViewContainer.addView(filterView,Utils.MATCH_WRAP_PARAMS);
  if (viewMode == ThreadManager.ViewMode.LIST) {
    ListView list=new ListView(getActivity());
    listView=list;
    postAdapter=new PostAdapter(getActivity(),threadManager,listView,this);
    listView.setAdapter(postAdapter);
    list.setSelectionFromTop(loadable.listViewIndex,loadable.listViewTop);
  }
 else   if (viewMode == ThreadManager.ViewMode.GRID) {
    GridView grid=new GridView(getActivity());
    grid.setNumColumns(GridView.AUTO_FIT);
    int postGridWidth=getActivity().getResources().getDimensionPixelSize(R.dimen.post_grid_width);
    grid.setColumnWidth(postGridWidth);
    listView=grid;
    postAdapter=new PostAdapter(getActivity(),threadManager,listView,this);
    listView.setAdapter(postAdapter);
    listView.setSelection(loadable.listViewIndex);
  }
  listView.setOnScrollListener(new OnScrollListener(){
    @Override public void onScrollStateChanged(    AbsListView view,    int scrollState){
      if (!isFiltering) {
        if (skipLogic != null) {
          skipLogic.onScrollStateChanged(view,scrollState);
        }
      }
    }
    @Override public void onScroll(    AbsListView view,    int firstVisibleItem,    int visibleItemCount,    int totalItemCount){
      if (!isFiltering) {
        if (loadable != null) {
          int index=view.getFirstVisiblePosition();
          View v=view.getChildAt(0);
          int top=v == null ? 0 : v.getTop();
          if (index != 0 || top != 0) {
            loadable.listViewIndex=index;
            loadable.listViewTop=top;
          }
        }
        if (skipLogic != null) {
          skipLogic.onScroll(view,firstVisibleItem,visibleItemCount,totalItemCount);
        }
      }
    }
  }
);
  listViewContainer.addView(listView,Utils.MATCH_PARAMS);
  compound.addView(listViewContainer,Utils.MATCH_PARAMS);
  if (loadable.isThreadMode()) {
    skip=new ImageView(getActivity());
    skip.setImageResource(R.drawable.skip_arrow_down);
    skip.setVisibility(View.GONE);
    compound.addView(skip,Utils.WRAP_PARAMS);
    RelativeLayout.LayoutParams params=(RelativeLayout.LayoutParams)skip.getLayoutParams();
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    params.setMargins(0,0,Utils.dp(8),Utils.dp(8));
    skip.setLayoutParams(params);
    skipLogic=new SkipLogic(skip,listView);
  }
  return compound;
}