use of com.zype.android.webapi.model.video.Pagination in project zype-android by zype.
the class VideosActivity method handleRetrieveVideo.
// //////////
// Subscriptions
//
@Subscribe
public void handleRetrieveVideo(RetrieveVideoEvent event) {
List<VideoData> result = event.getEventData().getModelData().getVideoData();
Pagination pagination = event.getEventData().getModelData().getPagination();
if (result != null) {
Logger.d("handleRetrieveVideo(): size=" + result.size());
if (result.size() > 0) {
if (mVideoList == null || pagination.getCurrent() == 1) {
mVideoList = new ArrayList<>(result);
} else {
mVideoList.addAll(result);
}
if (Pagination.hasNextPage(pagination)) {
loadVideosFromPlaylist(Pagination.getNextPage(pagination));
} else {
int videosAdded = DataHelper.insertVideos(this.getContentResolver(), mVideoList);
Logger.d("handleRetrieveVideo(): added " + videosAdded + " videos");
DataHelper.addVideosToPlaylist(this.getContentResolver(), mVideoList, playlistId);
DataHelper.clearPlaylistVideo(this.getContentResolver(), playlistId);
int itemsInsertedPlaylistVideo = DataHelper.insertPlaylistVideo(this.getContentResolver(), mVideoList, playlistId, 0);
Logger.d("handleRetrieveVideo(): PlaylistVideo inserted=" + itemsInsertedPlaylistVideo);
// if (videosAdded > 0) {
// startLoadCursors();
// }
}
}
}
}
Aggregations