Search in sources :

Example 41 with RequestOptions

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

the class GlideHelper method loadFull.

/**
 * Loads thumbnail and then replaces it with full image.
 */
public static void loadFull(ImageView image, int imageId, 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();
    final RequestBuilder<Drawable> thumbRequest = Glide.with(image).load(thumbId).apply(options);
    Glide.with(image).load(imageId).apply(options).thumbnail(thumbRequest).into(image);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Drawable(android.graphics.drawable.Drawable)

Example 42 with RequestOptions

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

the class DemoGlideHelper method loadFlickrFull.

public static void loadFlickrFull(Photo photo, ImageView image, LoadingListener listener) {
    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.getMediumUrl()).apply(options);
    Glide.with(image).load(photo.getLarge1600Url()).apply(new RequestOptions().apply(options).placeholder(image.getDrawable())).thumbnail(thumbRequest).listener(new RequestListenerWrapper<>(listener)).into(image);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Drawable(android.graphics.drawable.Drawable)

Example 43 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project PhotoPicker by donglua.

the class PhotoGridAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final PhotoViewHolder holder, int position) {
    if (getItemViewType(position) == ITEM_TYPE_PHOTO) {
        List<Photo> photos = getCurrentPhotos();
        final Photo photo;
        if (showCamera()) {
            photo = photos.get(position - 1);
        } else {
            photo = photos.get(position);
        }
        boolean canLoadImage = AndroidLifecycleUtils.canLoadImage(holder.ivPhoto.getContext());
        if (canLoadImage) {
            final RequestOptions options = new RequestOptions();
            options.centerCrop().dontAnimate().override(imageSize, imageSize).placeholder(R.drawable.__picker_ic_photo_black_48dp).error(R.drawable.__picker_ic_broken_image_black_48dp);
            glide.setDefaultRequestOptions(options).load(new File(photo.getPath())).thumbnail(0.5f).into(holder.ivPhoto);
        }
        final boolean isChecked = isSelected(photo);
        holder.vSelected.setSelected(isChecked);
        holder.ivPhoto.setSelected(isChecked);
        holder.ivPhoto.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                if (onPhotoClickListener != null) {
                    int pos = holder.getAdapterPosition();
                    if (previewEnable) {
                        onPhotoClickListener.onClick(view, pos, showCamera());
                    } else {
                        holder.vSelected.performClick();
                    }
                }
            }
        });
        holder.vSelected.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                int pos = holder.getAdapterPosition();
                boolean isEnable = true;
                if (onItemCheckListener != null) {
                    isEnable = onItemCheckListener.onItemCheck(pos, photo, getSelectedPhotos().size() + (isSelected(photo) ? -1 : 1));
                }
                if (isEnable) {
                    toggleSelection(photo);
                    notifyItemChanged(pos);
                }
            }
        });
    } else {
        holder.ivPhoto.setImageResource(R.drawable.__picker_camera);
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Photo(me.iwf.photopicker.entity.Photo) File(java.io.File) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 44 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project DevRing by LJYcoder.

the class GlideManager method load.

private RequestBuilder load(RequestBuilder requestBuilder, LoadOption loadOption) {
    RequestOptions requestOptions = new RequestOptions();
    mImageConfig = DevRing.ringComponent().imageConfig();
    // 使用全局的配置进行设置
    if (loadOption == null) {
        if (mImageConfig.isShowTransition()) {
            requestBuilder.transition(DrawableTransitionOptions.withCrossFade(600));
        }
        if (mImageConfig.getLoadingResId() > 0) {
            requestOptions.placeholder(mImageConfig.getLoadingResId());
        }
        if (mImageConfig.getErrorResId() > 0) {
            requestOptions.error(mImageConfig.getErrorResId());
        }
        requestOptions.skipMemoryCache(!mImageConfig.isUseMemoryCache());
        if (mImageConfig.isUseDiskCache()) {
            requestOptions.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC);
        } else {
            requestOptions.diskCacheStrategy(DiskCacheStrategy.NONE);
        }
    } else // 使用临时的配置进行设置
    {
        if (loadOption.isShowTransition()) {
            requestBuilder.transition(DrawableTransitionOptions.withCrossFade(600));
        }
        if (loadOption.getLoadingResId() > 0) {
            requestOptions.placeholder(loadOption.getLoadingResId());
        }
        if (loadOption.getErrorResId() > 0) {
            requestOptions.error(loadOption.getErrorResId());
        }
        requestOptions.skipMemoryCache(!loadOption.isUseMemoryCache());
        if (loadOption.isUseDiskCache()) {
            requestOptions.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC);
        } else {
            requestOptions.diskCacheStrategy(DiskCacheStrategy.NONE);
        }
        CircleBorderTransformation circleTransformation = null;
        // CropCircleTransformation circleTransformation = null;
        RoundedCornersTransformation roundedCornersTransformation = null;
        BlurTransformation blurTransformation = null;
        GrayscaleTransformation grayscaleTransformation = null;
        if (loadOption.isCircle()) {
            // circleTransformation = new CropCircleTransformation();
            int borderWidth = loadOption.getBorderWidth();
            int borderColor = loadOption.getBorderColor();
            if (borderWidth > 0 && borderColor != 0) {
                circleTransformation = new CircleBorderTransformation(borderWidth, borderColor);
            } else {
                circleTransformation = new CircleBorderTransformation();
            }
        } else if (loadOption.getRoundRadius() > 0) {
            roundedCornersTransformation = new RoundedCornersTransformation(loadOption.getRoundRadius(), 0);
        }
        if (loadOption.getBlurRadius() > 0) {
            blurTransformation = new BlurTransformation(loadOption.getBlurRadius());
        }
        if (loadOption.isGray()) {
            grayscaleTransformation = new GrayscaleTransformation();
        }
        MultiTransformation multiTransformation = getMultiTransformation(circleTransformation, roundedCornersTransformation, blurTransformation, grayscaleTransformation);
        if (multiTransformation != null)
            requestOptions.transform(multiTransformation);
    }
    return requestBuilder.apply(requestOptions);
}
Also used : BlurTransformation(jp.wasabeef.glide.transformations.BlurTransformation) RequestOptions(com.bumptech.glide.request.RequestOptions) CircleBorderTransformation(com.ljy.devring.image.support.CircleBorderTransformation) GrayscaleTransformation(jp.wasabeef.glide.transformations.GrayscaleTransformation) MultiTransformation(com.bumptech.glide.load.MultiTransformation) RoundedCornersTransformation(jp.wasabeef.glide.transformations.RoundedCornersTransformation)

Example 45 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project CustomViews by AndroidStudy233.

the class GlideUtils method loadCircleImg.

public static void loadCircleImg(Context context, String imageUrl, ImageView targetIv) {
    RequestOptions requestOptions = new RequestOptions();
    requestOptions.error(R.drawable.pic_head_deauft);
    requestOptions.circleCrop();
    Glide.with(context).load(imageUrl).apply(requestOptions).into(targetIv);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions)

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