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));
}
});
}
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);
}
}
}
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
}
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);
}
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;
}
Aggregations