Search in sources :

Example 6 with RoundedCorners

use of com.bumptech.glide.load.resource.bitmap.RoundedCorners 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 7 with RoundedCorners

use of com.bumptech.glide.load.resource.bitmap.RoundedCorners 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 8 with RoundedCorners

use of com.bumptech.glide.load.resource.bitmap.RoundedCorners 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 9 with RoundedCorners

use of com.bumptech.glide.load.resource.bitmap.RoundedCorners in project MVPArms by JessYanCoding.

the class GlideImageLoaderStrategy method loadImage.

@Override
public void loadImage(@Nullable Context ctx, @Nullable ImageConfigImpl config) {
    Preconditions.checkNotNull(ctx, "Context is required");
    Preconditions.checkNotNull(config, "ImageConfigImpl is required");
    Preconditions.checkNotNull(config.getImageView(), "ImageView is required");
    GlideRequests requests;
    // 如果context是activity则自动使用Activity的生命周期
    requests = GlideArms.with(ctx);
    GlideRequest<Drawable> glideRequest = requests.load(config.getUrl());
    switch(config.getCacheStrategy()) {
        // 缓存策略
        case CacheStrategy.NONE:
            glideRequest.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case CacheStrategy.RESOURCE:
            glideRequest.diskCacheStrategy(DiskCacheStrategy.RESOURCE);
            break;
        case CacheStrategy.DATA:
            glideRequest.diskCacheStrategy(DiskCacheStrategy.DATA);
            break;
        case CacheStrategy.AUTOMATIC:
            glideRequest.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC);
            break;
        default:
            glideRequest.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
    }
    if (config.isCrossFade()) {
        glideRequest.transition(DrawableTransitionOptions.withCrossFade());
    }
    if (config.isCenterCrop()) {
        glideRequest.centerCrop();
    }
    if (config.isCircle()) {
        glideRequest.circleCrop();
    }
    if (config.isImageRadius()) {
        glideRequest.transform(new RoundedCorners(config.getImageRadius()));
    }
    if (config.isBlurImage()) {
        glideRequest.transform(new BlurTransformation(config.getBlurValue()));
    }
    if (config.getTransformation() != null) {
        // glide用它来改变图形的形状
        glideRequest.transform(config.getTransformation());
    }
    if (// 设置占位符
    config.getPlaceholder() != 0) {
        glideRequest.placeholder(config.getPlaceholder());
    }
    if (// 设置错误的图片
    config.getErrorPic() != 0) {
        glideRequest.error(config.getErrorPic());
    }
    if (// 设置请求 url 为空图片
    config.getFallback() != 0) {
        glideRequest.fallback(config.getFallback());
    }
    glideRequest.into(config.getImageView());
}
Also used : Drawable(android.graphics.drawable.Drawable) RoundedCorners(com.bumptech.glide.load.resource.bitmap.RoundedCorners)

Example 10 with RoundedCorners

use of com.bumptech.glide.load.resource.bitmap.RoundedCorners in project Signal-Android by WhisperSystems.

the class ThumbnailView method setImageResource.

public ListenableFuture<Boolean> setImageResource(@NonNull GlideRequests glideRequests, @NonNull Uri uri, int width, int height) {
    SettableFuture<Boolean> future = new SettableFuture<>();
    if (transferControls.isPresent())
        getTransferControls().setVisibility(View.GONE);
    GlideRequest request = glideRequests.load(new DecryptableUri(uri)).diskCacheStrategy(DiskCacheStrategy.NONE).transition(withCrossFade());
    if (width > 0 && height > 0) {
        request = request.override(width, height);
    }
    if (radius > 0) {
        request = request.transforms(new CenterCrop(), new RoundedCorners(radius));
    } else {
        request = request.transforms(new CenterCrop());
    }
    request.into(new GlideDrawableListeningTarget(image, future));
    blurhash.setImageDrawable(null);
    return future;
}
Also used : SettableFuture(org.thoughtcrime.securesms.util.concurrent.SettableFuture) GlideRequest(org.thoughtcrime.securesms.mms.GlideRequest) DecryptableUri(org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri) CenterCrop(com.bumptech.glide.load.resource.bitmap.CenterCrop) RoundedCorners(com.bumptech.glide.load.resource.bitmap.RoundedCorners)

Aggregations

RoundedCorners (com.bumptech.glide.load.resource.bitmap.RoundedCorners)15 FitCenter (com.bumptech.glide.load.resource.bitmap.FitCenter)5 RequestOptions (com.bumptech.glide.request.RequestOptions)5 Bitmap (android.graphics.Bitmap)3 Drawable (android.graphics.drawable.Drawable)3 Test (org.junit.Test)3 CenterCrop (com.bumptech.glide.load.resource.bitmap.CenterCrop)2 DecryptableUri (org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri)2 GlideRequest (org.thoughtcrime.securesms.mms.GlideRequest)2 SettableFuture (org.thoughtcrime.securesms.util.concurrent.SettableFuture)2 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)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 NotificationCompat (androidx.core.app.NotificationCompat)1 NotificationManagerCompat (androidx.core.app.NotificationManagerCompat)1 RemoteInput (androidx.core.app.RemoteInput)1