Search in sources :

Example 21 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project MovieGuide by esoxjem.

the class MoviesListingAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    holder.itemView.setOnClickListener(holder);
    holder.movie = movies.get(position);
    holder.name.setText(holder.movie.getTitle());
    RequestOptions options = new RequestOptions().centerCrop().diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).priority(Priority.HIGH);
    Glide.with(context).asBitmap().load(Api.getPosterPath(holder.movie.getPosterPath())).apply(options).into(new BitmapImageViewTarget(holder.poster) {

        @Override
        public void onResourceReady(Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) {
            super.onResourceReady(bitmap, transition);
            Palette.from(bitmap).generate(palette -> setBackgroundColor(palette, holder));
        }
    });
}
Also used : Context(android.content.Context) Api(com.esoxjem.movieguide.Api) RequestOptions(com.bumptech.glide.request.RequestOptions) ButterKnife(butterknife.ButterKnife) LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) BitmapImageViewTarget(com.bumptech.glide.request.target.BitmapImageViewTarget) ViewGroup(android.view.ViewGroup) BindView(butterknife.BindView) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Glide(com.bumptech.glide.Glide) Priority(com.bumptech.glide.Priority) Bitmap(android.graphics.Bitmap) Transition(com.bumptech.glide.request.transition.Transition) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) R(com.esoxjem.movieguide.R) Palette(androidx.palette.graphics.Palette) Movie(com.esoxjem.movieguide.Movie) Bitmap(android.graphics.Bitmap) BitmapImageViewTarget(com.bumptech.glide.request.target.BitmapImageViewTarget) RequestOptions(com.bumptech.glide.request.RequestOptions)

Example 22 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project MovieGuide by esoxjem.

the class MovieDetailsFragment method showTrailers.

@Override
public void showTrailers(List<Video> trailers) {
    if (trailers.isEmpty()) {
        label.setVisibility(View.GONE);
        this.trailers.setVisibility(View.GONE);
        horizontalScrollView.setVisibility(View.GONE);
    } else {
        label.setVisibility(View.VISIBLE);
        this.trailers.setVisibility(View.VISIBLE);
        horizontalScrollView.setVisibility(View.VISIBLE);
        this.trailers.removeAllViews();
        LayoutInflater inflater = getActivity().getLayoutInflater();
        RequestOptions options = new RequestOptions().placeholder(R.color.colorPrimary).centerCrop().override(150, 150);
        for (Video trailer : trailers) {
            View thumbContainer = inflater.inflate(R.layout.video, this.trailers, false);
            ImageView thumbView = thumbContainer.findViewById(R.id.video_thumb);
            thumbView.setTag(R.id.glide_tag, Video.getUrl(trailer));
            thumbView.requestLayout();
            thumbView.setOnClickListener(this);
            Glide.with(requireContext()).load(Video.getThumbnailUrl(trailer)).apply(options).into(thumbView);
            this.trailers.addView(thumbContainer);
        }
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Video(com.esoxjem.movieguide.Video) LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView)

Example 23 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project android-booksearch-exercise by codepath.

the class BookAdapter method onBindViewHolder.

// Involves populating data into the item through holder
@Override
public void onBindViewHolder(BookAdapter.ViewHolder viewHolder, int position) {
    // Get the data model based on position
    Book book = mBooks.get(position);
    // Populate data into the template view using the data object
    viewHolder.tvTitle.setText(book.getTitle());
    viewHolder.tvAuthor.setText(book.getAuthor());
    Glide.with(getContext()).load(Uri.parse(book.getCoverUrl())).apply(new RequestOptions().placeholder(R.drawable.ic_nocover)).into(viewHolder.ivCover);
// Return the completed view to render on screen
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Book(com.codepath.android.booksearch.models.Book)

Example 24 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project plaid by nickbutcher.

the class PlaidGlideModule method applyOptions.

@Override
public void applyOptions(Context context, GlideBuilder builder) {
    // Prefer higher quality images unless we're on a low RAM device
    ActivityManager activityManager = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
    final RequestOptions defaultOptions = new RequestOptions().format(activityManager.isLowRamDevice() ? PREFER_RGB_565 : PREFER_ARGB_8888).disallowHardwareConfig();
    builder.setDefaultRequestOptions(defaultOptions);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) ActivityManager(android.app.ActivityManager)

Example 25 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project bdcodehelper by boredream.

the class BannerPagerAdapter method instantiateItem.

@Override
public Object instantiateItem(ViewGroup container, final int position) {
    final ImageUrlInterface image = images.get(position % images.size());
    View view = View.inflate(context, R.layout.item_image_banner, null);
    TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
    final ImageView iv = (ImageView) view.findViewById(R.id.iv_image);
    String title = image.getImageTitle();
    if (TextUtils.isEmpty(title)) {
        tv_title.setVisibility(View.GONE);
    } else {
        tv_title.setVisibility(View.VISIBLE);
        tv_title.setText(title);
    }
    final String url = image.getImageUrl();
    Glide.with(context).load(url).apply(new RequestOptions().centerCrop()).into(iv);
    iv.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (onBannerClickListener != null) {
                onBannerClickListener.onOnClick(position % images.size());
            } else {
                if (!TextUtils.isEmpty(image.getImageLink())) {
                    Intent intent = new Intent(context, WebViewActivity.class);
                    intent.putExtra("title", image.getImageTitle());
                    intent.putExtra("url", image.getImageLink());
                    context.startActivity(intent);
                } else {
                    ImageBrowserActivity.start(context, images, position % images.size());
                }
            }
        }
    });
    container.addView(view);
    return view;
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) ImageUrlInterface(com.boredream.bdcodehelper.entity.ImageUrlInterface) TextView(android.widget.TextView) Intent(android.content.Intent) ImageView(android.widget.ImageView) WebViewActivity(com.boredream.bdcodehelper.activity.WebViewActivity) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

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