use of com.zype.android.Db.Entity.Playlist in project zype-android by zype.
the class GalleryRowItemsAdapter method loadThumbnail.
private void loadThumbnail(ViewHolder holder) {
if (holder.item instanceof Video) {
Video video = (Video) holder.item;
boolean thumbnailAssigned = false;
if (usePoster && video.images != null) {
Image posterThumbnail = VideoHelper.getPosterThumbnail(video);
if (posterThumbnail != null) {
thumbnailAssigned = true;
UiUtils.loadImage(posterThumbnail.getUrl(), R.drawable.placeholder_video, holder.imageThumbnail);
}
}
if (video.thumbnails != null && !thumbnailAssigned) {
Thumbnail thumbnail = VideoHelper.getThumbnailByHeight(video, 240);
if (thumbnail != null) {
UiUtils.loadImage(thumbnail.getUrl(), R.drawable.placeholder_video, holder.imageThumbnail);
} else {
holder.imageThumbnail.setImageDrawable(ContextCompat.getDrawable(holder.view.getContext(), R.drawable.placeholder_video));
}
}
} else if (holder.item instanceof Playlist) {
Playlist playlist = (Playlist) holder.item;
boolean thumbnailAssigned = false;
if (usePoster && playlist.images != null) {
Image posterThumbnail = VideoHelper.getPosterThumbnail(playlist);
if (posterThumbnail != null) {
thumbnailAssigned = true;
UiUtils.loadImage(posterThumbnail.getUrl(), R.drawable.outline_video_library_white_48, holder.imageThumbnail);
}
}
if (playlist.thumbnails != null && !thumbnailAssigned) {
Type thumbnailType = new TypeToken<List<Thumbnail>>() {
}.getType();
List<Thumbnail> thumbnails = new Gson().fromJson(playlist.thumbnails, thumbnailType);
Thumbnail thumbnail = VideoHelper.getThumbnailByHeight(thumbnails, 240);
if (thumbnail != null) {
UiUtils.loadImage(thumbnail.getUrl(), R.drawable.outline_video_library_white_48, holder.imageThumbnail);
} else {
holder.imageThumbnail.setImageDrawable(ContextCompat.getDrawable(holder.view.getContext(), R.drawable.outline_video_library_white_48));
}
}
}
}
use of com.zype.android.Db.Entity.Playlist in project zype-android by zype.
the class GalleryViewModel method loadRowPlaylists.
private void loadRowPlaylists(GalleryRow row) {
row.pageToLoad = 1;
Map<String, String> parameters = new HashMap<>();
parameters.put(ZypeApi.PER_PAGE, String.valueOf(10));
final IZypeApiListener listener = new IZypeApiListener() {
@Override
public void onCompleted(ZypeApiResponse response) {
PlaylistsResponse playlistsResponse = (PlaylistsResponse) response.data;
if (response.isSuccessful) {
List<Playlist> result = new ArrayList<>();
for (com.zype.android.zypeapi.model.PlaylistData item : playlistsResponse.response) {
Playlist playlist = repo.getPlaylistSync(item.id);
if (playlist != null) {
result.add(DbHelper.playlistUpdateEntityByApi(playlist, item));
} else {
result.add(DbHelper.playlistApiToEntity(item));
}
}
repo.insertPlaylists(result);
row.nestedPlaylists = repo.getPlaylistsSync(row.playlist.id);
if (playlistsResponse.pagination.current >= playlistsResponse.pagination.pages) {
row.pageToLoad = -1;
row.state = UPDATED;
} else {
row.pageToLoad = playlistsResponse.pagination.next;
row.state = READY;
api.getPlaylists(row.playlist.id, row.pageToLoad, parameters, this);
Logger.d("loadRowPlaylists(): page=" + playlistsResponse.pagination.next);
}
updateGalleryRows(null);
} else {
// TODO: Handle api response error
if (playlistsResponse != null) {
// errorMessage.setValue(videosResponse.message);
} else {
// errorMessage.setValue(getApplication().getString(R.string.videos_error));
}
}
}
};
api.getPlaylists(row.playlist.id, row.pageToLoad, parameters, listener);
Logger.d("loadRowPlaylists(): page=" + row.pageToLoad);
}
use of com.zype.android.Db.Entity.Playlist 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