use of com.zype.android.zypeapi.model.VideoFavoriteData in project zype-android by zype.
the class DataRepository method loadVideoFavorites.
// Video favorites
public void loadVideoFavorites(IDataLoading listener) {
deleteVideoFavorites();
String accessToken = AuthHelper.getAccessToken();
String consumerId = SettingsProvider.getInstance().getConsumerId();
ZypeApi.getInstance().getVideoFavorites(accessToken, consumerId, (IZypeApiListener<VideoFavoritesResponse>) response -> {
if (response.isSuccessful) {
for (VideoFavoriteData item : response.data.videoFavorites) {
Video video = getVideoSync(item.videoId);
if (video == null) {
loadVideo(item.videoId, response1 -> {
if (response.isSuccessful) {
Video dbVideo = getVideoSync(item.videoId);
if (dbVideo != null) {
dbVideo.isFavorite = 1;
updateVideo(dbVideo);
FavoriteVideo favoriteVideo = new FavoriteVideo();
favoriteVideo.id = item.id;
favoriteVideo.videoId = item.videoId;
addVideoFavorite(favoriteVideo);
}
}
});
} else {
video.isFavorite = 1;
updateVideo(video);
FavoriteVideo favoriteVideo = new FavoriteVideo();
favoriteVideo.id = item.id;
favoriteVideo.videoId = item.videoId;
addVideoFavorite(favoriteVideo);
}
}
if (listener != null) {
listener.onLoadingCompleted(true);
}
} else {
if (listener != null) {
listener.onLoadingCompleted(false);
}
}
});
}
Aggregations