use of com.zype.fire.api.Model.VideoEntitlementData in project zype-firebuilder by zype.
the class EntitlementsManager method loadEntitlementsSubscription.
Subscription loadEntitlementsSubscription(int page, CompositeSubscription compositeSubscription) {
return Observable.just(true).subscribeOn(Schedulers.io()).observeOn(Schedulers.newThread()).subscribe(result -> {
String accessToken = Preferences.getString(ZypeAuthentication.ACCESS_TOKEN);
VideoEntitlementsResponse response = ZypeApi.getInstance().getVideoEntitlements(accessToken, page, ZypeApi.PER_PAGE_DEFAULT);
if (response != null) {
Log.d(TAG, "loadVideoEntitlements(): size=" + response.videoEntitlements.size());
for (VideoEntitlementData data : response.videoEntitlements) {
VideoEntitlementsHelper.getInstance().addVideoEntitlement(context, data.videoId, data.createdAt);
}
if (response.pagination.current < response.pagination.pages) {
compositeSubscription.add(loadEntitlementsSubscription(response.pagination.next, compositeSubscription));
}
}
}, throwable -> {
}, () -> {
});
}
use of com.zype.fire.api.Model.VideoEntitlementData in project zype-firebuilder by zype.
the class ContentLoader method getMyLibraryVideosObservable.
public Observable<Pair> getMyLibraryVideosObservable(Object contentContainerAsObject) {
ContentContainer contentContainer = (ContentContainer) contentContainerAsObject;
ContentContainer rootMyLibrary = getRootContentContainer().findContentContainerByName(ZypeSettings.ROOT_MY_LIBRARY_PLAYLIST_ID);
int nextPage = rootMyLibrary.getExtraValueAsInt(ExtraKeys.NEXT_PAGE);
if (nextPage <= 0) {
Log.e(TAG, "getMyLibraryVideosObservable(): incorrect page: " + nextPage);
return Observable.just(Pair.create(contentContainerAsObject, ""));
}
String accessToken = Preferences.getString(ZypeAuthentication.ACCESS_TOKEN);
VideoEntitlementsResponse response = ZypeApi.getInstance().getVideoEntitlements(accessToken, nextPage, ZypeApi.PER_PAGE_DEFAULT);
if (response != null) {
if (response.pagination.current == response.pagination.pages) {
rootMyLibrary.setExtraValue(ExtraKeys.NEXT_PAGE, -1);
} else {
rootMyLibrary.setExtraValue(ExtraKeys.NEXT_PAGE, response.pagination.next);
}
Log.d(TAG, "getMyLibraryVideosObservable(): size=" + response.videoEntitlements.size());
List<VideoData> videos = new ArrayList<>();
for (VideoEntitlementData data : response.videoEntitlements) {
VideoResponse responseVideo = ZypeApi.getInstance().getVideo(data.videoId);
if (responseVideo != null) {
VideoData videoData = responseVideo.videoData;
if (TextUtils.isEmpty(videoData.description) || videoData.description.equals("null")) {
videoData.description = " ";
}
videoData.playlistId = contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG);
videoData.playerUrl = "null";
videos.add(videoData);
} else {
Log.e(TAG, "getMyLibraryVideosObservable(): error loading video, id=" + data.videoId);
}
}
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
String feed = gson.toJson(videos);
return Observable.just(Pair.create(contentContainerAsObject, feed));
} else {
Log.e(TAG, "getMyLibraryVideosObservable(): no videos found");
return Observable.just(Pair.create(contentContainerAsObject, ""));
}
}
Aggregations