Search in sources :

Example 11 with RecentRecord

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;
}
Also used : ContentValues(android.content.ContentValues) RecentRecord(com.amazon.android.contentbrowser.database.records.RecentRecord) Date(java.util.Date)

Example 12 with RecentRecord

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;
}
Also used : RecentRecord(com.amazon.android.contentbrowser.database.records.RecentRecord)

Aggregations

RecentRecord (com.amazon.android.contentbrowser.database.records.RecentRecord)12 RecentDatabaseHelper (com.amazon.android.contentbrowser.database.helpers.RecentDatabaseHelper)5 ArrayList (java.util.ArrayList)3 Content (com.amazon.android.model.content.Content)2 ContentValues (android.content.ContentValues)1 Context (android.content.Context)1 Action (com.amazon.android.model.Action)1 ContentContainer (com.amazon.android.model.content.ContentContainer)1 Date (java.util.Date)1 List (java.util.List)1 Test (org.junit.Test)1