Search in sources :

Example 86 with RequestOptions

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

the class FeedSearchResultAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull Holder holder, int position) {
    final Feed podcast = data.get(position);
    holder.imageView.setContentDescription(podcast.getTitle());
    holder.imageView.setOnClickListener(v -> mainActivityRef.get().loadChildFragment(FeedItemlistFragment.newInstance(podcast.getId())));
    Glide.with(mainActivityRef.get()).load(podcast.getImageUrl()).apply(new RequestOptions().placeholder(R.color.light_gray).fitCenter().dontAnimate()).into(holder.imageView);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 87 with RequestOptions

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

the class NavListAdapter method bindFeedView.

private void bindFeedView(NavDrawerData.FeedDrawerItem drawerItem, FeedHolder holder) {
    Feed feed = drawerItem.feed;
    Activity context = activity.get();
    if (context == null) {
        return;
    }
    Glide.with(context).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(holder.image);
    if (feed.hasLastUpdateFailed()) {
        RelativeLayout.LayoutParams p = (RelativeLayout.LayoutParams) holder.title.getLayoutParams();
        p.addRule(RelativeLayout.LEFT_OF, R.id.itxtvFailure);
        holder.failure.setVisibility(View.VISIBLE);
    } else {
        RelativeLayout.LayoutParams p = (RelativeLayout.LayoutParams) holder.title.getLayoutParams();
        p.addRule(RelativeLayout.LEFT_OF, R.id.txtvCount);
        holder.failure.setVisibility(View.GONE);
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) RelativeLayout(android.widget.RelativeLayout) PreferenceActivity(de.danoeh.antennapod.activity.PreferenceActivity) Activity(android.app.Activity) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 88 with RequestOptions

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

the class StatisticsListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder h, int position) {
    if (getItemViewType(position) == TYPE_HEADER) {
        HeaderHolder holder = (HeaderHolder) h;
        holder.pieChart.setData(pieChartData);
        holder.totalTime.setText(getHeaderValue());
    } else {
        StatisticsHolder holder = (StatisticsHolder) h;
        StatisticsItem statsItem = statisticsData.get(position - 1);
        Glide.with(context).load(statsItem.feed.getImageUrl()).apply(new RequestOptions().placeholder(R.color.light_gray).error(R.color.light_gray).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).fitCenter().dontAnimate()).into(holder.image);
        holder.title.setText(statsItem.feed.getTitle());
        holder.chip.setTextColor(pieChartData.getColorOfItem(position - 1));
        onBindFeedViewHolder(holder, statsItem);
    }
}
Also used : StatisticsItem(de.danoeh.antennapod.core.storage.StatisticsItem) RequestOptions(com.bumptech.glide.request.RequestOptions)

Example 89 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project MaterialViewPager by florent37.

the class MaterialViewPagerImageHelper method setImageUrl.

/**
 * change the image with a fade
 *
 * @param urlImage
 * @param fadeDuration TODO : remove Picasso
 */
public static void setImageUrl(final ImageView imageView, final String urlImage, final int fadeDuration) {
    final float alpha = ViewCompat.getAlpha(imageView);
    final ImageView viewToAnimate = imageView;
    // fade to alpha=0
    fadeOut(viewToAnimate, fadeDuration, new ViewPropertyAnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(View view) {
            super.onAnimationEnd(view);
            // change the image when alpha=0
            Glide.with(imageView.getContext()).load(urlImage).apply(new RequestOptions().centerCrop()).listener(new RequestListener<Drawable>() {

                @Override
                public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                    return false;
                }

                @Override
                public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                    // then fade to alpha=1
                    new Handler(Looper.getMainLooper()) {
                    }.post(new Runnable() {

                        @Override
                        public void run() {
                            fadeIn(viewToAnimate, alpha, fadeDuration, new ViewPropertyAnimatorListenerAdapter());
                            if (imageLoadListener != null) {
                                imageLoadListener.OnImageLoad(imageView, ((BitmapDrawable) imageView.getDrawable()).getBitmap());
                            }
                        }
                    });
                    return false;
                }
            }).into(viewToAnimate);
        }
    });
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) Handler(android.os.Handler) ImageView(android.widget.ImageView) View(android.view.View) DataSource(com.bumptech.glide.load.DataSource) ImageView(android.widget.ImageView) ViewPropertyAnimatorListenerAdapter(android.support.v4.view.ViewPropertyAnimatorListenerAdapter) GlideException(com.bumptech.glide.load.engine.GlideException)

Example 90 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project GestureViews by alexvasilkov.

the class GlideHelper method loadThumb.

/**
 * Loads thumbnail.
 */
public static void loadThumb(ImageView image, int thumbId) {
    // We don't want Glide to crop or resize our image
    final RequestOptions options = new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE).override(Target.SIZE_ORIGINAL).dontTransform();
    Glide.with(image).load(thumbId).apply(options).into(image);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions)

Aggregations

RequestOptions (com.bumptech.glide.request.RequestOptions)96 ImageView (android.widget.ImageView)23 View (android.view.View)18 Drawable (android.graphics.drawable.Drawable)16 TextView (android.widget.TextView)13 Bitmap (android.graphics.Bitmap)9 BitmapDrawable (android.graphics.drawable.BitmapDrawable)8 File (java.io.File)8 Uri (android.net.Uri)7 ColorDrawable (android.graphics.drawable.ColorDrawable)6 Context (android.content.Context)5 Intent (android.content.Intent)5 RecyclerView (android.support.v7.widget.RecyclerView)5 DataSource (com.bumptech.glide.load.DataSource)5 GlideException (com.bumptech.glide.load.engine.GlideException)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