Search in sources :

Example 91 with RequestOptions

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;
}
Also used : Context(android.content.Context) RequestOptions(com.bumptech.glide.request.RequestOptions) Activity(android.app.Activity) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) Uri(android.net.Uri) File(java.io.File)

Example 92 with RequestOptions

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);
        }
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Uri(android.net.Uri) File(java.io.File)

Example 93 with RequestOptions

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);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Drawable(android.graphics.drawable.Drawable)

Example 94 with RequestOptions

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);
}
Also used : Context(android.content.Context) RequestOptions(com.bumptech.glide.request.RequestOptions)

Example 95 with RequestOptions

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);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) GifDrawable(com.bumptech.glide.load.resource.gif.GifDrawable) CenterCrop(com.bumptech.glide.load.resource.bitmap.CenterCrop) HookWXImageView(com.eros.framework.extend.hook.ui.view.HookWXImageView)

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