use of com.bumptech.glide.load.resource.bitmap.FitCenter in project AntennaPod by AntennaPod.
the class PodcastListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder holder;
GpodnetPodcast podcast = getItem(position);
// Inflate Layout
if (convertView == null) {
holder = new Holder();
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.gpodnet_podcast_listitem, parent, false);
holder.image = convertView.findViewById(R.id.imgvCover);
holder.title = convertView.findViewById(R.id.txtvTitle);
holder.subscribers = convertView.findViewById(R.id.txtvSubscribers);
holder.author = convertView.findViewById(R.id.txtvAuthor);
convertView.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
}
if (StringUtils.isNotBlank(podcast.getLogoUrl())) {
Glide.with(convertView.getContext()).load(podcast.getLogoUrl()).apply(new RequestOptions().placeholder(R.color.light_gray).error(R.color.light_gray).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).transforms(new FitCenter(), new RoundedCorners((int) (4 * convertView.getContext().getResources().getDisplayMetrics().density))).dontAnimate()).into(holder.image);
}
holder.title.setText(podcast.getTitle());
holder.subscribers.setText(String.valueOf(podcast.getSubscribers()));
holder.author.setText(podcast.getAuthor());
return convertView;
}
use of com.bumptech.glide.load.resource.bitmap.FitCenter in project AntennaPod by AntennaPod.
the class ItunesAdapter method getView.
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
// Current podcast
PodcastSearchResult podcast = data.get(position);
// ViewHolder
PodcastViewHolder viewHolder;
// Resulting view
View view;
// Handle view holder stuff
if (convertView == null) {
view = ((MainActivity) context).getLayoutInflater().inflate(R.layout.itunes_podcast_listitem, parent, false);
viewHolder = new PodcastViewHolder(view);
view.setTag(viewHolder);
} else {
view = convertView;
viewHolder = (PodcastViewHolder) view.getTag();
}
// Set the title
viewHolder.titleView.setText(podcast.title);
if (podcast.author != null && !podcast.author.trim().isEmpty()) {
viewHolder.authorView.setText(podcast.author);
viewHolder.authorView.setVisibility(View.VISIBLE);
} else if (podcast.feedUrl != null && !podcast.feedUrl.contains("itunes.apple.com")) {
viewHolder.authorView.setText(podcast.feedUrl);
viewHolder.authorView.setVisibility(View.VISIBLE);
} else {
viewHolder.authorView.setVisibility(View.GONE);
}
// Update the empty imageView with the image from the feed
Glide.with(context).load(podcast.imageUrl).apply(new RequestOptions().placeholder(R.color.light_gray).diskCacheStrategy(DiskCacheStrategy.NONE).transforms(new FitCenter(), new RoundedCorners((int) (4 * context.getResources().getDisplayMetrics().density))).dontAnimate()).into(viewHolder.coverView);
// Feed the grid view
return view;
}
use of com.bumptech.glide.load.resource.bitmap.FitCenter in project AntennaPod by AntennaPod.
the class ChaptersListAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull ChapterHolder holder, int position) {
Chapter sc = getItem(position);
if (sc == null) {
holder.title.setText("Error");
return;
}
holder.title.setText(sc.getTitle());
holder.start.setText(Converter.getDurationStringLong((int) sc.getStart()));
long duration;
if (position + 1 < media.getChapters().size()) {
duration = media.getChapters().get(position + 1).getStart() - sc.getStart();
} else {
duration = media.getDuration() - sc.getStart();
}
holder.duration.setText(context.getString(R.string.chapter_duration, Converter.getDurationStringLocalized(context, (int) duration)));
if (TextUtils.isEmpty(sc.getLink())) {
holder.link.setVisibility(View.GONE);
} else {
holder.link.setVisibility(View.VISIBLE);
holder.link.setText(sc.getLink());
holder.link.setOnClickListener(v -> IntentUtils.openInBrowser(context, sc.getLink()));
}
holder.secondaryActionIcon.setImageResource(R.drawable.ic_play_48dp);
holder.secondaryActionButton.setContentDescription(context.getString(R.string.play_chapter));
holder.secondaryActionButton.setOnClickListener(v -> {
if (callback != null) {
callback.onPlayChapterButtonClicked(position);
}
});
if (position == currentChapterIndex) {
int playingBackGroundColor = ThemeUtils.getColorFromAttr(context, R.attr.currently_playing_background);
holder.itemView.setBackgroundColor(playingBackGroundColor);
float progress = ((float) (currentChapterPosition - sc.getStart())) / duration;
progress = Math.max(progress, CircularProgressBar.MINIMUM_PERCENTAGE);
progress = Math.min(progress, CircularProgressBar.MAXIMUM_PERCENTAGE);
holder.progressBar.setPercentage(progress, position);
holder.secondaryActionIcon.setImageResource(R.drawable.ic_replay);
} else {
holder.itemView.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent));
holder.progressBar.setPercentage(0, null);
}
if (hasImages) {
holder.image.setVisibility(View.VISIBLE);
if (TextUtils.isEmpty(sc.getImageUrl())) {
Glide.with(context).clear(holder.image);
} else {
Glide.with(context).load(EmbeddedChapterImage.getModelFor(media, position)).apply(new RequestOptions().diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).dontAnimate().transforms(new FitCenter(), new RoundedCorners((int) (4 * context.getResources().getDisplayMetrics().density)))).into(holder.image);
}
} else {
holder.image.setVisibility(View.GONE);
}
}
use of com.bumptech.glide.load.resource.bitmap.FitCenter in project Signal-Android by WhisperSystems.
the class BitmapUtil method createScaledBitmapInto.
private static <T> Bitmap createScaledBitmapInto(Context context, T model, int width, int height) throws BitmapDecodingException {
final Bitmap rough = Downsampler.AT_LEAST.decode(getInputStreamForModel(context, model), Glide.get(context).getBitmapPool(), width, height, DecodeFormat.PREFER_RGB_565);
final Resource<Bitmap> resource = BitmapResource.obtain(rough, Glide.get(context).getBitmapPool());
final Resource<Bitmap> result = new FitCenter(context).transform(resource, width, height);
if (result == null) {
throw new BitmapDecodingException("unable to transform Bitmap");
}
return result.get();
}
use of com.bumptech.glide.load.resource.bitmap.FitCenter in project AntennaPod by AntennaPod.
the class CoverFragment method displayCoverImage.
private void displayCoverImage() {
RequestOptions options = new RequestOptions().diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).dontAnimate().transforms(new FitCenter(), new RoundedCorners((int) (16 * getResources().getDisplayMetrics().density)));
RequestBuilder<Drawable> cover = Glide.with(this).load(media.getImageLocation()).error(Glide.with(this).load(ImageResourceUtils.getFallbackImageLocation(media)).apply(options)).apply(options);
if (displayedChapterIndex == -1 || media == null || media.getChapters() == null || TextUtils.isEmpty(media.getChapters().get(displayedChapterIndex).getImageUrl())) {
cover.into(imgvCover);
} else {
Glide.with(this).load(EmbeddedChapterImage.getModelFor(media, displayedChapterIndex)).apply(options).thumbnail(cover).error(cover).into(imgvCover);
}
}
Aggregations