use of com.zype.android.zypeapi.model.VideoResponse in project zype-android by zype.
the class VideoDetailViewModel method loadVideo.
// Zype API
/**
* Make API request for video
*
* @param videoId Video id
*/
private void loadVideo(String videoId) {
Logger.d("loadVideo(): videoId=" + videoId);
final IZypeApiListener listener = new IZypeApiListener() {
@Override
public void onCompleted(ZypeApiResponse response) {
VideoResponse videoResponse = (VideoResponse) response.data;
if (response.isSuccessful) {
Video video = repo.getVideoSync(videoId);
if (video != null) {
video = DbHelper.videoUpdateEntityByApi(video, videoResponse.videoData);
} else {
video = DbHelper.videoApiToEntity(videoResponse.videoData);
}
repo.updateVideo(video);
} else {
// TODO: Add error handling
}
}
};
api.getVideo(videoId, false, listener);
// VideoParamsBuilder builder = new VideoParamsBuilder()
// .addVideoId(videoId);
// oldApi.executeRequest(WebApiManager.Request.VIDEO, builder.build());
}
use of com.zype.android.zypeapi.model.VideoResponse in project zype-android by zype.
the class MainActivity method switchToLiveVideo.
private void switchToLiveVideo() {
// show loader
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress);
progressBar.setVisibility(View.VISIBLE);
ZypeApi zypeApi = ZypeApi.getInstance();
zypeApi.getVideo(ZypeSettings.LIVE_VIDEO_ID, false, response -> {
progressBar.setVisibility(View.GONE);
if (response.isSuccessful) {
VideoResponse videoResponse = (VideoResponse) response.data;
DataRepository repo = DataRepository.getInstance(getApplication());
Video video = repo.getVideoSync(ZypeSettings.LIVE_VIDEO_ID);
if (video != null) {
video = DbHelper.videoUpdateEntityByApi(video, videoResponse.videoData);
repo.updateVideo(video);
} else {
video = DbHelper.videoApiToEntity(videoResponse.videoData);
List<Video> videos = new ArrayList<>();
videos.add(video);
repo.insertVideos(videos);
}
NavigationHelper.getInstance(this).switchToVideoDetailsScreen(this, video.id, null, false);
} else {
UiUtils.showErrorSnackbar(findViewById(R.id.root_view), getString(R.string.live_video_load_error_message));
if (refreshTab) {
bottomNavigationView.setSelectedItemId(lastSelectedTabId);
}
}
});
}
Aggregations