Search in sources :

Example 1 with VideoEntitlementData

use of com.zype.android.webapi.model.entitlements.VideoEntitlementData in project zype-android by zype.

the class MyLibraryFragment method handleRetrieveVideo.

@Subscribe
public void handleRetrieveVideo(RetrieveVideoEvent event) {
    Logger.d("handleRetrieveVideo(): size=" + event.getEventData().getModelData().getVideoData().size());
    Video data = event.getEventData().getModelData();
    if (data.getVideoData().size() > 0) {
        for (VideoData item : data.getVideoData()) {
            if (videoEntitlements.containsKey(item.getId())) {
                List<VideoData> videos = new ArrayList<>();
                videos.add(item);
                DataHelper.insertVideos(getActivity().getContentResolver(), videos);
                VideoEntitlementData entitlementData = videoEntitlements.get(item.getId());
                if (entitlementData != null) {
                    VideoHelper.setEntitlement(getActivity().getContentResolver(), item.getId(), true, entitlementData.updatedAt);
                }
            }
        }
    }
}
Also used : Video(com.zype.android.webapi.model.video.Video) ConsumerFavoriteVideo(com.zype.android.webapi.model.consumers.ConsumerFavoriteVideo) VideoData(com.zype.android.webapi.model.video.VideoData) ConsumerFavoriteVideoData(com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData) ArrayList(java.util.ArrayList) VideoEntitlementData(com.zype.android.webapi.model.entitlements.VideoEntitlementData) Subscribe(com.squareup.otto.Subscribe)

Example 2 with VideoEntitlementData

use of com.zype.android.webapi.model.entitlements.VideoEntitlementData in project zype-android by zype.

the class MyLibraryFragment method handleVideoEntitlements.

// ///////////
// Subscriptions
// 
@Subscribe
public void handleVideoEntitlements(VideoEntitlementsEvent event) {
    VideoEntitlements data = event.getEventData().getModelData();
    Logger.d("handleVideoEntitlements(): size=" + data.videoEntitlements.size());
    for (VideoEntitlementData item : data.videoEntitlements) {
        videoEntitlements.put(item.videoId, item);
    }
    if (Pagination.hasNextPage(data.pagination) && !data.videoEntitlements.isEmpty()) {
        requestVideoEntitlements(Pagination.getNextPage(data.pagination));
    } else {
        // Clear entitlement flag in all existing videos
        VideoHelper.setEntitlement(getActivity().getContentResolver(), null, false, "");
        // Load videos with entitlements
        for (String videoId : videoEntitlements.keySet()) {
            VideoParamsBuilder builder = new VideoParamsBuilder().addVideoId(videoId);
            getApi().executeRequest(WebApiManager.Request.VIDEO_LATEST_GET, builder.build());
        }
    }
}
Also used : VideoParamsBuilder(com.zype.android.webapi.builder.VideoParamsBuilder) VideoEntitlementData(com.zype.android.webapi.model.entitlements.VideoEntitlementData) VideoEntitlements(com.zype.android.webapi.model.entitlements.VideoEntitlements) Subscribe(com.squareup.otto.Subscribe)

Aggregations

Subscribe (com.squareup.otto.Subscribe)2 VideoEntitlementData (com.zype.android.webapi.model.entitlements.VideoEntitlementData)2 VideoParamsBuilder (com.zype.android.webapi.builder.VideoParamsBuilder)1 ConsumerFavoriteVideo (com.zype.android.webapi.model.consumers.ConsumerFavoriteVideo)1 ConsumerFavoriteVideoData (com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData)1 VideoEntitlements (com.zype.android.webapi.model.entitlements.VideoEntitlements)1 Video (com.zype.android.webapi.model.video.Video)1 VideoData (com.zype.android.webapi.model.video.VideoData)1 ArrayList (java.util.ArrayList)1