Search in sources :

Example 1 with Pagination

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();
            // }
            }
        }
    }
}
Also used : Pagination(com.zype.android.webapi.model.video.Pagination) VideoData(com.zype.android.webapi.model.video.VideoData) ConsumerFavoriteVideoData(com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData) Subscribe(com.squareup.otto.Subscribe)

Aggregations

Subscribe (com.squareup.otto.Subscribe)1 ConsumerFavoriteVideoData (com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData)1 Pagination (com.zype.android.webapi.model.video.Pagination)1 VideoData (com.zype.android.webapi.model.video.VideoData)1