예제 #1
0
  @NonNull
  public static Tweet tweetFromCursor(Cursor cursor) {
    Tweet tweet =
        new Tweet(
            cursor.getString(cursor.getColumnIndex(KEY_TWEET_TEXT)),
            cursor.getDouble(cursor.getColumnIndex(KEY_TWEET_LATITUDE)),
            cursor.getDouble(cursor.getColumnIndex(KEY_TWEET_LONGITUDE)),
            cursor.getString(cursor.getColumnIndex(KEY_TWEET_IMAGE_URL)));

    tweet.setId(cursor.getLong(cursor.getColumnIndex(KEY_TWEET_ID)));

    long creationDate = cursor.getLong(cursor.getColumnIndex(KEY_TWEET_CREATION_DATE));
    tweet.setCreationDate(DBHelper.convertLongToDate(creationDate));

    long modificationDate = cursor.getLong(cursor.getColumnIndex(KEY_TWEET_MODIFICATION_DATE));
    tweet.setModificationDate(DBHelper.convertLongToDate(modificationDate));

    return tweet;
  }