use of com.bumptech.glide.request.RequestOptions in project PhotoPicker by donglua.
the class PhotoPagerAdapter method instantiateItem.
@Override
public Object instantiateItem(ViewGroup container, int position) {
final Context context = container.getContext();
View itemView = LayoutInflater.from(context).inflate(R.layout.__picker_picker_item_pager, container, false);
final ImageView imageView = (ImageView) itemView.findViewById(R.id.iv_pager);
final String path = paths.get(position);
final Uri uri;
if (path.startsWith("http")) {
uri = Uri.parse(path);
} else {
uri = Uri.fromFile(new File(path));
}
boolean canLoadImage = AndroidLifecycleUtils.canLoadImage(context);
if (canLoadImage) {
final RequestOptions options = new RequestOptions();
options.dontAnimate().dontTransform().override(800, 800).placeholder(R.drawable.__picker_ic_photo_black_48dp).error(R.drawable.__picker_ic_broken_image_black_48dp);
mGlide.setDefaultRequestOptions(options).load(uri).thumbnail(0.1f).into(imageView);
}
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (context instanceof Activity) {
if (!((Activity) context).isFinishing()) {
((Activity) context).onBackPressed();
}
}
}
});
container.addView(itemView);
return itemView;
}
use of com.bumptech.glide.request.RequestOptions in project PhotoPicker by donglua.
the class PhotoAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final PhotoViewHolder holder, final int position) {
if (getItemViewType(position) == TYPE_PHOTO) {
Uri uri = Uri.fromFile(new File(photoPaths.get(position)));
boolean canLoadImage = AndroidLifecycleUtils.canLoadImage(holder.ivPhoto.getContext());
if (canLoadImage) {
final RequestOptions options = new RequestOptions();
options.centerCrop().placeholder(R.drawable.__picker_ic_photo_black_48dp).error(R.drawable.__picker_ic_broken_image_black_48dp);
Glide.with(mContext).load(uri).apply(options).thumbnail(0.1f).into(holder.ivPhoto);
}
}
}
use of com.bumptech.glide.request.RequestOptions in project GestureViews by alexvasilkov.
the class DemoGlideHelper method loadFlickrThumb.
public static void loadFlickrThumb(Photo photo, ImageView image) {
final RequestOptions options = new RequestOptions().diskCacheStrategy(DiskCacheStrategy.DATA).override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).dontTransform();
final RequestBuilder<Drawable> thumbRequest = Glide.with(image).load(photo.getThumbnailUrl()).apply(options).transition(DrawableTransitionOptions.with(TRANSITION_FACTORY));
Glide.with(image).load(photo.getMediumUrl()).apply(options).thumbnail(thumbRequest).into(image);
}
use of com.bumptech.glide.request.RequestOptions in project FlexibleAdapter by davideas.
the class InstagramItem method bindViewHolder.
@Override
public void bindViewHolder(final FlexibleAdapter adapter, ViewHolder holder, int position, List payloads) {
Context context = holder.itemView.getContext();
holder.mQuantityLikes.setText(context.getResources().getString(R.string.likes, getLikes()));
holder.mImageFavourite.flipSilently(getStarred());
// Load image via Glide
RequestOptions options = new RequestOptions().optionalFitCenter();
Glide.with(context.getApplicationContext()).asBitmap().apply(options).transition(withCrossFade(200)).load(url).into(holder.mImage);
}
use of com.bumptech.glide.request.RequestOptions in project WeexErosFramework by bmfe.
the class DefaultWXImageAdapter method setImage.
@Override
public void setImage(final String url, final ImageView view, WXImageQuality quality, final WXImageStrategy strategy) {
if (view == null || !(view instanceof HookWXImageView))
return;
final String loadUri = url;
if (HookImage.AUTORECYCLE_URL.equals(loadUri)) {
// wximage被回收
view.setImageBitmap(null);
return;
}
final HookWXImageView wxImageView = (HookWXImageView) view;
if (TextUtils.isEmpty(loadUri)) {
// 设置的src为null
wxImageView.setImageBitmap(null);
handleError(wxImageView);
if (strategy != null && strategy.getImageListener() != null) {
strategy.getImageListener().onImageFinish(loadUri, view, true, null);
}
return;
}
wxImageView.hideErrorBitmap();
// set placeHolder
if (isDefaultPlaceHolder(strategy)) {
int[] wh = WXCommonUtil.getComponentWH(wxImageView.getComponent());
wxImageView.showLoading(wh[0], wh[1]);
} else if (isCustomPlaceHolder(strategy)) {
// customer placeHolder
BMHookGlide.load(BMWXApplication.getWXApplication(), strategy.placeHolder).apply(new RequestOptions().fitCenter().diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)).into(wxImageView);
} else {
// no placeHolder
// 防止复用出现的问题
wxImageView.hideLoading();
}
DefaultImageViewTarget viewTarget = new DefaultImageViewTarget(wxImageView);
viewTarget.setImageLoadListener(new DefaultImageViewTarget.ImageLoadListener() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
if (strategy != null && strategy.getImageListener() != null) {
strategy.getImageListener().onImageFinish(loadUri, wxImageView, true, null);
}
if (isDefaultPlaceHolder(strategy)) {
wxImageView.hideLoading();
}
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
handleError((HookWXImageView) wxImageView);
if (strategy != null && strategy.getImageListener() != null) {
strategy.getImageListener().onImageFinish(loadUri, wxImageView, true, null);
}
if (isDefaultPlaceHolder(strategy)) {
wxImageView.hideLoading();
}
}
});
BMHookGlide.load(BMWXApplication.getWXApplication(), loadUri).apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).transforms(new CenterCrop())).into(viewTarget);
}
Aggregations