Search in sources :

Example 1 with FitCenter

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;
}
Also used : GpodnetPodcast(de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast) RequestOptions(com.bumptech.glide.request.RequestOptions) LayoutInflater(android.view.LayoutInflater) FitCenter(com.bumptech.glide.load.resource.bitmap.FitCenter) RoundedCorners(com.bumptech.glide.load.resource.bitmap.RoundedCorners)

Example 2 with FitCenter

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;
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) FitCenter(com.bumptech.glide.load.resource.bitmap.FitCenter) MainActivity(de.danoeh.antennapod.activity.MainActivity) RoundedCorners(com.bumptech.glide.load.resource.bitmap.RoundedCorners) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) PodcastSearchResult(de.danoeh.antennapod.discovery.PodcastSearchResult) NonNull(androidx.annotation.NonNull)

Example 3 with FitCenter

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);
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Chapter(de.danoeh.antennapod.model.feed.Chapter) FitCenter(com.bumptech.glide.load.resource.bitmap.FitCenter) RoundedCorners(com.bumptech.glide.load.resource.bitmap.RoundedCorners)

Example 4 with FitCenter

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();
}
Also used : Bitmap(android.graphics.Bitmap) FitCenter(com.bumptech.glide.load.resource.bitmap.FitCenter)

Example 5 with FitCenter

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);
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Drawable(android.graphics.drawable.Drawable) FitCenter(com.bumptech.glide.load.resource.bitmap.FitCenter) RoundedCorners(com.bumptech.glide.load.resource.bitmap.RoundedCorners)

Aggregations

FitCenter (com.bumptech.glide.load.resource.bitmap.FitCenter)6 RoundedCorners (com.bumptech.glide.load.resource.bitmap.RoundedCorners)5 RequestOptions (com.bumptech.glide.request.RequestOptions)5 Bitmap (android.graphics.Bitmap)1 Drawable (android.graphics.drawable.Drawable)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 MainActivity (de.danoeh.antennapod.activity.MainActivity)1 PodcastSearchResult (de.danoeh.antennapod.discovery.PodcastSearchResult)1 Chapter (de.danoeh.antennapod.model.feed.Chapter)1 GpodnetPodcast (de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast)1