Search in sources :

Example 6 with RecentDatabaseHelper

use of com.amazon.android.contentbrowser.database.helpers.RecentDatabaseHelper in project zype-firebuilder by zype.

the class ContentBrowser method getRecentContent.

/**
 * Get a list of contents to display in the "Continue Watching" row that have been watched for
 * more than the grace period value located in the custom.xml as recent_grace_period.
 *
 * @return A list of contents.
 */
public List<Content> getRecentContent() {
    List<Content> contentList = new ArrayList<>();
    RecentDatabaseHelper databaseHelper = RecentDatabaseHelper.getInstance();
    if (databaseHelper != null) {
        List<RecentRecord> records = databaseHelper.getUnfinishedRecords(mAppContext, mAppContext.getResources().getInteger(R.integer.recent_grace_period));
        for (RecentRecord record : records) {
            Content content = mContentLoader.getRootContentContainer().findContentById(record.getContentId());
            if (content != null) {
                contentList.add(content);
            }
        }
    }
    return contentList;
}
Also used : RecentDatabaseHelper(com.amazon.android.contentbrowser.database.helpers.RecentDatabaseHelper) Content(com.amazon.android.model.content.Content) ArrayList(java.util.ArrayList) RecentRecord(com.amazon.android.contentbrowser.database.records.RecentRecord)

Example 7 with RecentDatabaseHelper

use of com.amazon.android.contentbrowser.database.helpers.RecentDatabaseHelper in project zype-firebuilder by zype.

the class ContentBrowser method getRecentRecord.

/**
 * Get Recent Record from database based on content id
 *
 * @param content Content.
 * @return Recent Record.
 */
public RecentRecord getRecentRecord(Content content) {
    RecentRecord record = null;
    RecentDatabaseHelper databaseHelper = RecentDatabaseHelper.getInstance();
    if (databaseHelper != null) {
        if (databaseHelper.recordExists(mAppContext, content.getId())) {
            record = databaseHelper.getRecord(mAppContext, content.getId());
        }
    } else {
        Log.e(TAG, "Unable to load content because database is null");
    }
    return record;
}
Also used : RecentDatabaseHelper(com.amazon.android.contentbrowser.database.helpers.RecentDatabaseHelper) RecentRecord(com.amazon.android.contentbrowser.database.records.RecentRecord)

Aggregations

RecentDatabaseHelper (com.amazon.android.contentbrowser.database.helpers.RecentDatabaseHelper)7 RecentRecord (com.amazon.android.contentbrowser.database.records.RecentRecord)5 Content (com.amazon.android.model.content.Content)3 ArrayList (java.util.ArrayList)2 RecommendationDatabaseHelper (com.amazon.android.contentbrowser.database.helpers.RecommendationDatabaseHelper)1 ContentUpdateEvent (com.amazon.android.model.event.ContentUpdateEvent)1 List (java.util.List)1