Program: 56394
Project: 56394
Buggy source:
/** 
 * Check into a movie on trakt. Think of this method as in between a seen and a scrobble. After checking in, the trakt will automatically display it as watching then switch over to watched status once the duration has elapsed.
 * @param movieId The database id of the movie.
 */
public void checkin(final long movieId,final String message,final boolean facebook,final boolean twitter,final boolean tumblr){
  execute(new Runnable(){
    @Override public void run(){
      Cursor watching=context.getContentResolver().query(Movies.WATCHING,new String[]{MovieColumns.RUNTIME,MovieColumns.EXPIRES_AT},null,null,null);
      watching.moveToFirst();
      final long currentTime=System.currentTimeMillis();
      final int runtime=Cursors.getInt(watching,MovieColumns.RUNTIME);
      final long expires=Cursors.getLong(watching,MovieColumns.EXPIRES_AT);
      final long watchSlop=(long)(runtime * DateUtils.MINUTE_IN_MILLIS * 0.8f);
      Cursor movie=context.getContentResolver().query(Movies.withId(movieId),new String[]{MovieColumns.TITLE},null,null,null);
      movie.moveToFirst();
      final String title=Cursors.getString(movie,MovieColumns.TITLE);
      movie.close();
      if (watching.getCount() == 0 || ((expires - watchSlop) < currentTime && expires > 0)) {
        if (checkIn.movie(movieId,message,facebook,twitter,tumblr)) {
          movieHelper.checkIn(movieId);
        }
      }
 else {
        ErrorEvent.post(context.getString(R.string.checkin_error_watching,title));
      }
      watching.close();
      queue(new SyncWatching());
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Check into a movie on trakt. Think of this method as in between a seen and a scrobble. After checking in, the trakt will automatically display it as watching then switch over to watched status once the duration has elapsed.
 * @param movieId The database id of the movie.
 */
public void checkin(final long movieId,final String message,final boolean facebook,final boolean twitter,final boolean tumblr){
  execute(new Runnable(){
    @Override public void run(){
      Cursor watching=context.getContentResolver().query(Movies.WATCHING,new String[]{MovieColumns.RUNTIME,MovieColumns.EXPIRES_AT},null,null,null);
      if (watching.moveToFirst()) {
        final long currentTime=System.currentTimeMillis();
        final int runtime=Cursors.getInt(watching,MovieColumns.RUNTIME);
        final long expires=Cursors.getLong(watching,MovieColumns.EXPIRES_AT);
        final long watchSlop=(long)(runtime * DateUtils.MINUTE_IN_MILLIS * 0.8f);
        Cursor movie=context.getContentResolver().query(Movies.withId(movieId),new String[]{MovieColumns.TITLE},null,null,null);
        movie.moveToFirst();
        final String title=Cursors.getString(movie,MovieColumns.TITLE);
        movie.close();
        if ((expires - watchSlop) < currentTime && expires > 0) {
          if (checkIn.movie(movieId,message,facebook,twitter,tumblr)) {
            movieHelper.checkIn(movieId);
          }
        }
 else {
          ErrorEvent.post(context.getString(R.string.checkin_error_watching,title));
        }
      }
 else {
        if (checkIn.movie(movieId,message,facebook,twitter,tumblr)) {
          movieHelper.checkIn(movieId);
        }
      }
      watching.close();
      queue(new SyncWatching());
    }
  }
);
}