Search in sources :

Example 1 with CircleBorderTransformation

use of com.ljy.devring.image.support.CircleBorderTransformation 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)

Aggregations

MultiTransformation (com.bumptech.glide.load.MultiTransformation)1 RequestOptions (com.bumptech.glide.request.RequestOptions)1 CircleBorderTransformation (com.ljy.devring.image.support.CircleBorderTransformation)1 BlurTransformation (jp.wasabeef.glide.transformations.BlurTransformation)1 GrayscaleTransformation (jp.wasabeef.glide.transformations.GrayscaleTransformation)1 RoundedCornersTransformation (jp.wasabeef.glide.transformations.RoundedCornersTransformation)1