use of com.zype.android.ui.NavigationHelper in project zype-android by zype.
the class VideosFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
model = ViewModelProviders.of(this).get(PlaylistVideosViewModel.class);
model.setPlaylistId(playlistId);
showProgress();
model.getVideos().observe(this, videos -> {
if (videos.state == DataState.READY) {
Logger.d("getVideos(): size=" + videos.data.size());
adapter.setData(videos.data);
hideProgress();
} else if (videos.state == DataState.LOADING) {
showProgress();
} else if (videos.state == DataState.ERROR) {
hideProgress();
if (!TextUtils.isEmpty(videos.errorMessage)) {
hideProgress();
Snackbar.make(getView(), videos.errorMessage, Snackbar.LENGTH_INDEFINITE).show();
}
}
});
model.getSelectedVideo().observe(this, video -> {
if (video != null) {
NavigationHelper navigationHelper = NavigationHelper.getInstance(getActivity());
navigationHelper.handleVideoClick(getActivity(), video, playlistId, false);
model.onSelectedVideoProcessed();
}
});
adapter.setVideoListener((video) -> {
model.onVideoClicked(video);
});
adapter.setPopupMenuListener((action, video) -> {
model.handleVideoAction(action, video, success -> {
if (success) {
model.retrieveVideos(false);
} else {
NavigationHelper.getInstance(getActivity()).switchToLoginScreen(getActivity());
}
});
});
}
use of com.zype.android.ui.NavigationHelper in project zype-android by zype.
the class FavoritesFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
model = ViewModelProviders.of(getActivity()).get(FavoriteVideosViewModel.class);
showProgress();
model.getVideos().observe(this, videos -> {
if (!AuthHelper.isLoggedIn() && ZypeApp.get(getActivity()).getAppConfiguration().hideFavoritesActionWhenSignedOut) {
showEmpty(true);
return;
}
if (videos == null) {
return;
}
if (videos.data == null) {
Logger.e("getVideos(): videos list is mull");
showEmpty(true);
} else {
Logger.d("getVideos(): size=" + videos.data.size());
adapter.setData(videos.data);
if (videos.data.size() > 0) {
showEmpty(false);
} else {
showEmpty(true);
}
}
hideProgress();
});
model.getSelectedVideo().observe(this, video -> {
if (video != null) {
NavigationHelper navigationHelper = NavigationHelper.getInstance(getActivity());
navigationHelper.handleVideoClick(getActivity(), video, null, false);
model.onSelectedVideoProcessed();
}
});
adapter.setVideoListener((video) -> {
model.onVideoClicked(video);
});
adapter.setPopupMenuListener((action, video) -> {
model.handleVideoAction(action, video, success -> {
if (success) {
model.retrieveVideos(false);
} else {
NavigationHelper.getInstance(getActivity()).switchToLoginScreen(getActivity());
}
});
});
}
use of com.zype.android.ui.NavigationHelper in project zype-android by zype.
the class HeroImageFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_hero_image, container, false);
final NavigationHelper navigationHelper = NavigationHelper.getInstance(getActivity());
ImageView imageHero = rootView.findViewById(R.id.imageHero);
UiUtils.loadImage(getActivity(), imageUrl, imageHero);
imageHero.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!TextUtils.isEmpty(videoId)) {
Video video = DataRepository.getInstance(getActivity().getApplication()).getVideoSync(videoId);
if (video == null || video.active != 1) {
DialogHelper.showErrorAlert(getActivity(), getString(R.string.gallery_hero_image_error_video));
} else {
navigationHelper.handleVideoClick(getActivity(), video, null, false);
}
} else if (!TextUtils.isEmpty(playlistId)) {
Playlist playlist = DataRepository.getInstance(getActivity().getApplication()).getPlaylistSync(playlistId);
if (playlist == null || playlist.active != 1) {
DialogHelper.showErrorAlert(getActivity(), getString(R.string.gallery_hero_image_error_playlist));
} else {
navigationHelper.handlePlaylistClick(getActivity(), playlist);
}
}
}
});
return rootView;
}
Aggregations