use of com.zype.fire.api.Model.VideoFavoritesResponse in project zype-firebuilder by zype.
the class ZypeDataDownloaderHelper method loadFavoriteVideos.
public static VideosResult loadFavoriteVideos(String favoritesPlaylistId, String consumerId, String accessToken, int page) {
Log.d(TAG, "loadFavoriteVideos(): consumerId=" + consumerId);
VideosResult result = new VideosResult();
result.nextPage = page;
boolean loadNext = true;
while (loadNext) {
VideoFavoritesResponse response = ZypeApi.getInstance().getVideoFavorites(consumerId, accessToken, result.nextPage);
if (response != null) {
Log.d(TAG, "loadFavoriteVideos(): size=" + response.videoFavorites.size());
if (result.videos == null) {
result.videos = new ArrayList<>();
}
if (response.pagination.current >= response.pagination.pages) {
result.nextPage = -1;
} else {
result.nextPage = response.pagination.next;
}
for (VideoFavoriteData data : response.videoFavorites) {
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 = favoritesPlaylistId;
videoData.playerUrl = "null";
videoData.videoFavoriteId = data.id;
result.videos.add(videoData);
} else {
Log.e(TAG, "loadFavoriteVideos(): error loading video, id=" + data.videoId);
}
}
} else {
Log.e(TAG, "loadFavoriteVideos(): failed");
return null;
}
// Load all favorites
loadNext = !(result.nextPage == -1);
}
return result;
}
use of com.zype.fire.api.Model.VideoFavoritesResponse in project zype-firebuilder by zype.
the class ZypeApi method getVideoFavorites.
public VideoFavoritesResponse getVideoFavorites(String consumerId, String accessToken, int page) {
try {
HashMap<String, String> params = new HashMap<>();
params.put(ACCESS_TOKEN, accessToken);
params.put(PAGE, String.valueOf(page));
params.put(PER_PAGE, String.valueOf(PER_PAGE_DEFAULT));
params.put("sort", "created_at");
params.put("order", "desc");
Response response = apiImpl.getVideoFavorites(consumerId, params).execute();
if (response.isSuccessful()) {
return (VideoFavoritesResponse) response.body();
} else {
return null;
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
Aggregations