Program: 4044
Project: 4044
Buggy source:
private void setupFragment(){
  VerticalGridPresenter gridPresenter=new VerticalGridPresenter();
  Comparator<Video> videoNameComparator=new Comparator<Video>(){
    @Override public int compare(    Video o1,    Video o2){
      if (o2.getName() == null) {
        return (o1.getName() == null) ? 0 : -1;
      }
      if (o1.getName() == null) {
        return 1;
      }
      return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase());
    }
  }
;
  String selectedGenre=getActivity().getIntent().getStringExtra(Constants.GENRE);
  boolean isMovie=getActivity().getIntent().getBooleanExtra(Constants.IS_VIDEO,true);
  if (isMovie) {
    gridPresenter.setNumberOfColumns(NUM_COLUMNS);
    setGridPresenter(gridPresenter);
    mAdapter=new SortedObjectAdapter(videoNameComparator,new CardPresenter(getActivity()));
    List<Video> videos=Video.findWithQuery(Video.class,"String_Node_Str" + "String_Node_Str" + selectedGenre + "String_Node_Str");
    setTitle(selectedGenre + "String_Node_Str" + getString(R.string.movies)+ "String_Node_Str"+ videos.size()+ "String_Node_Str");
    for (    Video video : videos) {
      mAdapter.add(video);
    }
  }
 else {
    gridPresenter.setNumberOfColumns(NUM_COLUMNS - 2);
    setGridPresenter(gridPresenter);
    mAdapter=new SortedObjectAdapter(videoNameComparator,new TvShowsCardPresenter(getActivity()));
    List<Video> tvshows=Video.findWithQuery(Video.class,"String_Node_Str" + "String_Node_Str" + selectedGenre + "String_Node_Str");
    setTitle(selectedGenre + "String_Node_Str" + getString(R.string.tv_shows)+ "String_Node_Str"+ tvshows.size()+ "String_Node_Str");
    Map<String,VideoGroup> tvShowsMap=new TreeMap<String,VideoGroup>();
    for (    Video video : tvshows) {
      if (tvShowsMap.containsKey(video.getName())) {
        VideoGroup group=tvShowsMap.get(video.getName());
        if (TextUtils.isEmpty(group.getVideo().getCardImageUrl())) {
          group.getVideo().setCardImageUrl(video.getCardImageUrl());
        }
        group.increment();
      }
 else {
        VideoGroup vg=new VideoGroup(video);
        tvShowsMap.put(video.getName(),vg);
      }
    }
    if (tvShowsMap.size() > 0) {
      for (      VideoGroup videoGroup : tvShowsMap.values()) {
        mAdapter.add(videoGroup);
      }
    }
  }
  setAdapter(mAdapter);
  setOnItemClickedListener(new OnItemClickedListener(){
    @Override public void onItemClicked(    Object item,    Row row){
      if (item instanceof VideoGroup) {
        Intent intent=new Intent(getActivity(),DetailsActivity.class);
        intent.putExtra(Constants.IS_VIDEO,false);
        intent.putExtra(Constants.VIDEO_GROUP,(VideoGroup)item);
        startActivity(intent);
      }
 else       if (((Video)item).isMatched()) {
        Intent intent=new Intent(getActivity(),DetailsActivity.class);
        intent.putExtra(Constants.IS_VIDEO,true);
        intent.putExtra(Constants.VIDEO,(Video)item);
        startActivity(intent);
      }
    }
  }
);
  setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    Object o,    Row row){
    }
  }
);
}

Fixed version (ground truth):
private void setupFragment(){
  VerticalGridPresenter gridPresenter=new VerticalGridPresenter();
  String selectedGenre=getActivity().getIntent().getStringExtra(Constants.GENRE);
  boolean isMovie=getActivity().getIntent().getBooleanExtra(Constants.IS_VIDEO,true);
  ArrayObjectAdapter adapter;
  if (isMovie) {
    gridPresenter.setNumberOfColumns(NUM_COLUMNS);
    setGridPresenter(gridPresenter);
    adapter=new ArrayObjectAdapter(new CardPresenter(getActivity()));
    String sql="String_Node_Str" + "String_Node_Str" + selectedGenre + "String_Node_Str";
    List<Video> videos=Video.findWithQuery(Video.class,sql);
    setTitle(selectedGenre);
    adapter.addAll(0,videos);
  }
 else {
    gridPresenter.setNumberOfColumns(NUM_COLUMNS - 2);
    setGridPresenter(gridPresenter);
    adapter=new ArrayObjectAdapter(new TvShowsCardPresenter(getActivity()));
    String sql="String_Node_Str" + "String_Node_Str" + selectedGenre + "String_Node_Str";
    List<Video> tvshows=Video.findWithQuery(Video.class,sql);
    setTitle(selectedGenre);
    Map<String,VideoGroup> tvShowsMap=new TreeMap<String,VideoGroup>();
    for (    Video video : tvshows) {
      if (tvShowsMap.containsKey(video.getName())) {
        VideoGroup group=tvShowsMap.get(video.getName());
        if (TextUtils.isEmpty(group.getVideo().getCardImageUrl())) {
          group.getVideo().setCardImageUrl(video.getCardImageUrl());
        }
        group.increment();
      }
 else {
        VideoGroup vg=new VideoGroup(video);
        tvShowsMap.put(video.getName(),vg);
      }
    }
    if (tvShowsMap.size() > 0) {
      adapter.addAll(0,tvShowsMap.values());
    }
  }
  setAdapter(adapter);
  setOnItemClickedListener(new OnItemClickedListener(){
    @Override public void onItemClicked(    Object item,    Row row){
      if (item instanceof VideoGroup) {
        Intent intent=new Intent(getActivity(),DetailsActivity.class);
        intent.putExtra(Constants.IS_VIDEO,false);
        intent.putExtra(Constants.VIDEO_GROUP,(VideoGroup)item);
        startActivity(intent);
      }
 else       if (((Video)item).isMatched()) {
        Intent intent=new Intent(getActivity(),DetailsActivity.class);
        intent.putExtra(Constants.IS_VIDEO,true);
        intent.putExtra(Constants.VIDEO,(Video)item);
        startActivity(intent);
      }
    }
  }
);
  setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    Object item,    Row row){
      if (item instanceof Video) {
        try {
          mBackgroundImageUrl=((Video)item).getBackgroundImageUrl();
          startBackgroundTimer();
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
 else       if (item instanceof VideoGroup) {
        try {
          mBackgroundImageUrl=((VideoGroup)item).getVideo().getBackgroundImageUrl();
          startBackgroundTimer();
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
);
}