use of com.amazon.android.model.event.ContentUpdateEvent in project zype-firebuilder by zype.
the class PlaybackActivity method storeContentPlaybackState.
/**
* Store the current playback state of the selected content to the database. Calculates if
* playback was finished or not using the {@link ContentBrowser#GRACE_TIME_MS}.
* If the content playback is finished, recommendation manager will dismiss the recommendation
* for this content (if it exists).
*/
private void storeContentPlaybackState() {
// Calculate if the content has finished playing
boolean isFinished = (mPlayer.getDuration() - ContentBrowser.GRACE_TIME_MS) <= mPlayer.getCurrentPosition();
RecommendationDatabaseHelper recommendationDatabaseHelper = RecommendationDatabaseHelper.getInstance();
// Dismiss the recommendation notification for this content if the content is finished.
if (isFinished && recommendationDatabaseHelper != null) {
if (recommendationDatabaseHelper.recordExists(getApplicationContext(), mSelectedContent.getId())) {
ContentBrowser.getInstance(this).getRecommendationManager().dismissRecommendation(mSelectedContent.getId());
AnalyticsHelper.trackDismissRecommendationForCompleteContent(mSelectedContent);
}
}
// Save the recently played content to database
RecentDatabaseHelper recentDatabaseHelper = RecentDatabaseHelper.getInstance();
if (recentDatabaseHelper != null && !isContentLive(mSelectedContent)) {
recentDatabaseHelper.addRecord(getApplicationContext(), mSelectedContent.getId(), mPlayer.getCurrentPosition(), isFinished, DateAndTimeHelper.getCurrentDate().getTime(), mPlayer.getDuration());
if (ZypeConfiguration.displayWatchedBarOnVideoThumbnails()) {
EventBus.getDefault().post(new ContentUpdateEvent(mSelectedContent.getId()));
}
Log.d(TAG, "storeContentPlaybackState(): saved position " + mPlayer.getCurrentPosition());
} else {
Log.e(TAG, "Cannot update recent content playback state. Database is null");
}
}
Aggregations