use of com.zype.android.zypeapi.ZypeApi 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