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

The following examples show how to use com.bumptech.glide.request.RequestOptions#transforms() . 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: NewsGlideModule.java    From NewsApp with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@GlideOption
public static RequestOptions roundedCornerImage(RequestOptions options, @NonNull Context context, int radius) {
    if (radius > 0) {
        int px = Math.round(radius * (context.getResources().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
        return options.transforms(new CenterCrop(), new RoundedCorners(px));
    }
    return options.transforms(new CenterCrop());
}
 
Example 6
Source File: GlideImageLoader.java    From NIM_Android_UIKit with MIT License 5 votes vote down vote up
private static void displayAlbum(ImageView imageView, String path, Transformation<Bitmap> transformation,
                                 int placeHoder) {
    Context context = imageView.getContext();
    RequestOptions options = new RequestOptions().error(placeHoder).placeholder(placeHoder).diskCacheStrategy(
            DiskCacheStrategy.RESOURCE);

    if (transformation != null) {
        options = options.transforms(new CenterCrop(), transformation);
    } else {
        options = options.transform(new CenterCrop());
    }

    Glide.with(context).asDrawable().apply(options).load(Uri.fromFile(new File(path))).into(imageView);
}
 
Example 7
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);
                }
            }
        });
    }
}