Search in sources :

Example 26 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project AntennaPod by AntennaPod.

the class ApGlideModule method applyOptions.

@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
    builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_ARGB_8888));
    @SuppressLint("UsableSpace") long spaceAvailable = context.getCacheDir().getUsableSpace();
    long imageCacheSize = (spaceAvailable > 2 * GIGABYTES) ? (250 * MEGABYTES) : (50 * MEGABYTES);
    Log.d(TAG, "Free space on cache dir: " + spaceAvailable + ", using image cache size: " + imageCacheSize);
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, imageCacheSize));
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) SuppressLint(android.annotation.SuppressLint) InternalCacheDiskCacheFactory(com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory)

Example 27 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project AntennaPod by AntennaPod.

the class FeedInfoFragment method showFeed.

private void showFeed() {
    Log.d(TAG, "Language is " + feed.getLanguage());
    Log.d(TAG, "Author is " + feed.getAuthor());
    Log.d(TAG, "URL is " + feed.getDownload_url());
    Glide.with(getContext()).load(feed.getImageUrl()).apply(new RequestOptions().placeholder(R.color.light_gray).error(R.color.light_gray).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).fitCenter().dontAnimate()).into(imgvCover);
    Glide.with(getContext()).load(feed.getImageUrl()).apply(new RequestOptions().placeholder(R.color.image_readability_tint).error(R.color.image_readability_tint).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).transform(new FastBlurTransformation()).dontAnimate()).into(imgvBackground);
    txtvTitle.setText(feed.getTitle());
    txtvTitle.setMaxLines(6);
    String description = HtmlToPlainText.getPlainText(feed.getDescription());
    txtvDescription.setText(description);
    if (!TextUtils.isEmpty(feed.getAuthor())) {
        txtvAuthorHeader.setText(feed.getAuthor());
    }
    txtvUrl.setText(feed.getDownload_url() + " {fa-paperclip}");
    if (feed.getPaymentLinks() == null || feed.getPaymentLinks().size() == 0) {
        lblSupport.setVisibility(View.GONE);
        txtvFundingUrl.setVisibility(View.GONE);
    } else {
        lblSupport.setVisibility(View.VISIBLE);
        ArrayList<FeedFunding> fundingList = feed.getPaymentLinks();
        StringBuilder str = new StringBuilder();
        HashSet<String> seen = new HashSet<String>();
        for (FeedFunding funding : fundingList) {
            if (seen.contains(funding.url)) {
                continue;
            }
            seen.add(funding.url);
            str.append(funding.content.isEmpty() ? getContext().getResources().getString(R.string.support_podcast) : funding.content).append(" ").append(funding.url);
            str.append("\n");
        }
        str = new StringBuilder(StringUtils.trim(str.toString()));
        txtvFundingUrl.setText(str.toString());
    }
    Iconify.addIcons(txtvUrl);
    refreshToolbarState();
}
Also used : FastBlurTransformation(de.danoeh.antennapod.core.glide.FastBlurTransformation) RequestOptions(com.bumptech.glide.request.RequestOptions) FeedFunding(de.danoeh.antennapod.model.feed.FeedFunding) HashSet(java.util.HashSet)

Example 28 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project AntennaPod by AntennaPod.

the class FeedItemlistFragment method loadFeedImage.

private void loadFeedImage() {
    Glide.with(getActivity()).load(feed.getImageUrl()).apply(new RequestOptions().placeholder(R.color.image_readability_tint).error(R.color.image_readability_tint).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).transform(new FastBlurTransformation()).dontAnimate()).into(imgvBackground);
    Glide.with(getActivity()).load(feed.getImageUrl()).apply(new RequestOptions().placeholder(R.color.light_gray).error(R.color.light_gray).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).fitCenter().dontAnimate()).into(imgvCover);
}
Also used : FastBlurTransformation(de.danoeh.antennapod.core.glide.FastBlurTransformation) RequestOptions(com.bumptech.glide.request.RequestOptions)

Example 29 with RequestOptions

use of com.bumptech.glide.request.RequestOptions 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 30 with RequestOptions

use of com.bumptech.glide.request.RequestOptions 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)

Aggregations

RequestOptions (com.bumptech.glide.request.RequestOptions)104 ImageView (android.widget.ImageView)23 Drawable (android.graphics.drawable.Drawable)18 View (android.view.View)18 TextView (android.widget.TextView)13 Bitmap (android.graphics.Bitmap)11 File (java.io.File)10 BitmapDrawable (android.graphics.drawable.BitmapDrawable)9 ColorDrawable (android.graphics.drawable.ColorDrawable)7 Uri (android.net.Uri)7 DataSource (com.bumptech.glide.load.DataSource)6 GlideException (com.bumptech.glide.load.engine.GlideException)6 Context (android.content.Context)5 Intent (android.content.Intent)5 RecyclerView (android.support.v7.widget.RecyclerView)5 FitCenter (com.bumptech.glide.load.resource.bitmap.FitCenter)5 RoundedCorners (com.bumptech.glide.load.resource.bitmap.RoundedCorners)5 Test (org.junit.Test)5 Activity (android.app.Activity)3 LayoutInflater (android.view.LayoutInflater)3