Java Code Examples for com.bumptech.glide.request.RequestOptions#override()

The following examples show how to use com.bumptech.glide.request.RequestOptions#override() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageViewerActivity.java    From titanium-imagepicker with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void setupGlideOptions() {
   	options = new RequestOptions();

   	if (isShapeCircle) {
   		if (Defaults.CIRCLE_RADIUS > 0) {
   			options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS));

   		} else {
   			options.circleCrop();
   		}
   	}

   	options.override(Defaults.IMAGE_HEIGHT, Defaults.IMAGE_HEIGHT);
   	options.placeholder(placeholder_image);
   	options.priority(Priority.HIGH);
}
 
Example 2
Source File: ImagePickerActivity.java    From titanium-imagepicker with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void setupGlideOptions() {
   	options = new RequestOptions();
   	int size;

   	if (isShapeCircle) {
   		if (Defaults.CIRCLE_RADIUS > 0) {
   			size = (int) (0.65 * Defaults.IMAGE_HEIGHT);
   			options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS));

   		} else {
   			size = Defaults.IMAGE_HEIGHT;
   			options.circleCrop();
   		}

   	} else {
   		size = (int) (0.65 * Defaults.IMAGE_HEIGHT);
   	}

   	options.override(size, size);
   	options.error(error_image);
   	options.priority(Priority.HIGH);
   }
 
Example 3
Source File: ImageViewerActivity.java    From titanium-imagepicker with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void setupGlideOptions() {
   	options = new RequestOptions();

   	if (isShapeCircle) {
   		if (Defaults.CIRCLE_RADIUS > 0) {
   			options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS));

   		} else {
   			options.circleCrop();
   		}
   	}

   	options.override(Defaults.IMAGE_HEIGHT, Defaults.IMAGE_HEIGHT);
   	options.placeholder(placeholder_image);
   	options.priority(Priority.HIGH);
}
 
Example 4
Source File: ImagePickerActivity.java    From titanium-imagepicker with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "deprecation" })
private void setupGlideOptions() {
    	options = new RequestOptions();
    	int size;

    	if (isShapeCircle) {
    		if (Defaults.CIRCLE_RADIUS > 0) {
    			size = (int) (0.65 * Defaults.IMAGE_HEIGHT);
    			options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS));

    		} else {
    			size = Defaults.IMAGE_HEIGHT;
    			options.circleCrop();
    		}

    	} else {
    		size = (int) (0.65 * Defaults.IMAGE_HEIGHT);
    	}

    	options.override(size, size);
    	options.error(error_image);
    	options.priority(Priority.HIGH);
   }
 
Example 5
Source File: AvatarCropFragment.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
private void onPresentImage(ImageView imageView, String imageUri, int size) {
    RequestOptions options = new RequestOptions();
    options.fitCenter();
    options.override(Target.SIZE_ORIGINAL);
    Glide.with(imageView.getContext())
            .load(new File(imageUri))
            .apply(options)
            .into(imageView);

}
 
Example 6
Source File: GlideImageLoaderStrategy.java    From NewFastFrame with Apache License 2.0 4 votes vote down vote up
@Override
public void loadImage(Context context, GlideImageLoaderConfig config) {
    if (config == null || context == null) {
        return;
    }
    RequestBuilder drawableRequestBuilder;
    if (config.asGif()) {
        drawableRequestBuilder = Glide.with(context).asGif().load(config.getUrl());
    } else {
        drawableRequestBuilder = Glide.with(context).load(config.getUrl());
    }
    RequestOptions options = new RequestOptions();
    switch (config.getCacheStrategy()) {
        case GlideImageLoaderConfig.CACHE_ALL:
            options.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
        case GlideImageLoaderConfig.CACHE_NONE:
            options.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case GlideImageLoaderConfig.CACHE_SOURCE:
            options.diskCacheStrategy(DiskCacheStrategy.RESOURCE);
            break;
        case GlideImageLoaderConfig.CACHE_RESULT:
            options.diskCacheStrategy(DiskCacheStrategy.DATA);
            break;
        default:
            break;
    }
    if (config.isCenterInside()) {
        options = options.fitCenter();
    } else {
        options = options.centerCrop();
    }
    if (config.getBitmapTransformation() != null) {
        options = options.transforms(config.getBitmapTransformation());
    }
    if (config.getErrorResId() != 0) {
        options = options.error(config.getErrorResId());
    }
    if (config.getPlaceHolderResId() != 0) {
        options = options.placeholder(config.getPlaceHolderResId());
    }
    if (config.getWidth() != 0 && config.getHeight() != 0) {
        options = options.override(config.getWidth(), config.getHeight());
    }


    if (config.getView() instanceof ImageView) {
        drawableRequestBuilder.apply(options).into((ImageView) config.getView());
    } else {
        drawableRequestBuilder.apply(options).into(new SimpleTarget<Drawable>() {
            @Override
            public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
                if (config.getView()!=null) {
                    config.getView().setBackground(resource);
                }
            }
        });
    }
}