use of com.amazon.android.contentbrowser.database.records.RecentRecord in project zype-firebuilder by zype.
the class RecentTable method writeContentValues.
/**
* Fills the content values with the necessary information to save the recent record to the
* database.
*
* @param record The record.
* @return The content values.
*/
@Override
public ContentValues writeContentValues(Record record) {
ContentValues contentValues = new ContentValues();
RecentRecord recentRecord = (RecentRecord) record;
contentValues.put(COLUMN_CONTENT_ID, recentRecord.getContentId());
contentValues.put(COLUMN_PLAYBACK_LOCATION, recentRecord.getPlaybackLocation());
contentValues.put(COLUMN_COMPLETED, recentRecord.isPlaybackComplete());
Date expiration = DateAndTimeHelper.addSeconds(DateAndTimeHelper.getCurrentDate(), RECORD_TTL);
// 12 days (in seconds)
contentValues.put(COLUMN_EXPIRATION, expiration.getTime());
contentValues.put(COLUMN_LAST_WATCHED, recentRecord.getLastWatched());
contentValues.put(COLUMN_DURATION, recentRecord.getDuration());
return contentValues;
}
use of com.amazon.android.contentbrowser.database.records.RecentRecord in project zype-firebuilder by zype.
the class RecentTable method readRecordFromCursor.
/**
* Reads a recent record from a cursor. Does not close the cursor when finished.
*
* @param cursor The cursor containing the data to read.
* @return The recent record.
*/
@Override
public RecentRecord readRecordFromCursor(Cursor cursor) {
if (cursor == null) {
return null;
}
// skipping 0 since that's the row id and we don't need it right now.
int column = 1;
RecentRecord record = new RecentRecord();
record.setContentId(cursor.getString(column++));
record.setPlaybackLocation(cursor.getLong(column++));
record.setPlaybackComplete(cursor.getInt(column++) > 0);
// Skip expiration
column++;
record.setLastWatched(cursor.getLong(column++));
record.setDuration(cursor.getLong(column));
Log.d(TAG, "read recent record: " + record.toString());
return record;
}
Aggregations