当前位置: 首页>>代码示例>>Java>>正文


Java DrawableRequestBuilder.transform方法代码示例

本文整理汇总了Java中com.bumptech.glide.DrawableRequestBuilder.transform方法的典型用法代码示例。如果您正苦于以下问题:Java DrawableRequestBuilder.transform方法的具体用法?Java DrawableRequestBuilder.transform怎么用?Java DrawableRequestBuilder.transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.bumptech.glide.DrawableRequestBuilder的用法示例。


在下文中一共展示了DrawableRequestBuilder.transform方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDrawableRequestBuilder

import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
/**
 * DrawableRequestBuilder 的通行配置
 * @param ctx 上下文
 * @param img ImageLoader封装器
 * @param typeRequest url or resource
 * @param <T> String or Integer
 * @return DrawableRequestBuilder<T>
 */
private <T> DrawableRequestBuilder<T> getDrawableRequestBuilder(Context ctx, ImageLoader img, DrawableTypeRequest<T> typeRequest) {
    DrawableRequestBuilder<T> builder = typeRequest
            .placeholder(img.placeHolder)
            .error(img.errorHolder)
            .diskCacheStrategy(DiskCacheStrategy.ALL);

    // transform image type
    int transType = img.transType;
    if (transType == LoaderConfig.TRANS_CIRCLE) {
        builder = builder.transform(new GlideCircleTransform(ctx));
    } else if (transType == LoaderConfig.TRANS_ROUND) {
        builder = builder.transform(new GlideRoundTransform(ctx));
    }

    // SCALE type
    if (img.scaleType == LoaderConfig.SCALE_CENTER_CROP) {
        builder = builder.centerCrop();
    } else if (img.scaleType == LoaderConfig.SCALE_FIT_CENTER) {
        builder = builder.fitCenter();
    }
    return builder;
}
 
开发者ID:BlueYangDroid,项目名称:MvpPlus,代码行数:31,代码来源:GlideImageLoaderStrategy.java

示例2: loadResourceImage

import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
public static void loadResourceImage(Context context, ImageView view, int resId,
                                     @Nullable BitmapTransformation transformation) {
    DrawableRequestBuilder<Integer> request = Glide
            .with(context)
            .load(resId)
            .dontAnimate()
            .diskCacheStrategy(DiskCacheStrategy.SOURCE);
    if (transformation != null) {
        request.transform(transformation);
    }
    request.into(view);
}
 
开发者ID:WangDaYeeeeee,项目名称:Mysplash,代码行数:13,代码来源:ImageHelper.java

示例3: bindLibrary

import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
private void bindLibrary(final LibraryHolder holder, final Library lib) {
    holder.name.setText(lib.name);
    holder.description.setText(lib.description);
    DrawableRequestBuilder<String> request = Glide.with(holder.image.getContext())
            .load(lib.imageUrl)
            .placeholder(R.drawable.avatar_placeholder);
    if (lib.circleCrop) {
        request.transform(circleCrop);
    }
    request.into(holder.image);
}
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:12,代码来源:AboutActivity.java

示例4: loadImage

import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
@Override
public void loadImage(Context ctx, GlideImageConfig config) {
    if (ctx == null) throw new IllegalStateException("Context is required");
    if (config == null) throw new IllegalStateException("GlideImageConfig is required");
    if (TextUtils.isEmpty(config.getUrl())) throw new IllegalStateException("url is required");
    if (config.getImageView() == null) throw new IllegalStateException("imageview is required");


    RequestManager manager;

    manager = Glide.with(ctx);//如果context是activity则自动使用Activity的生命周期

    DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
            .crossFade()
            .centerCrop();

    switch (config.getCacheStrategy()) {//缓存策略
        case 0:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
        case 1:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case 2:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
            break;
        case 3:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
            break;
    }

    if (config.getTransformation() != null) {//glide用它来改变图形的形状
        requestBuilder.transform(config.getTransformation());
    }


    if (config.getPlaceholder() != 0)//设置占位符
        requestBuilder.placeholder(config.getPlaceholder());

    if (config.getErrorPic() != 0)//设置错误的图片
        requestBuilder.error(config.getErrorPic());

    requestBuilder
            .into(config.getImageView());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:46,代码来源:GlideImageLoaderStrategy.java

示例5: loadImage

import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
@Override
    public void loadImage(Context ctx, GlideImageConfig config) {
        if (ctx == null) throw new IllegalStateException("Context is required");
        if (config == null) throw new IllegalStateException("GlideImageConfig is required");
        //这里不抛异常空的就显示默认图片
//        if (TextUtils.isEmpty(config.getUrl())) throw new IllegalStateException("url is required");
        if (config.getImageView() == null) throw new IllegalStateException("imageview is required");


        RequestManager manager;

        manager = Glide.with(ctx);//如果context是activity则自动使用Activity的生命周期

        DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
                .centerCrop();

        if (config.fitCenter()) {
            requestBuilder.fitCenter();
        }

        if (config.dontAnimation()) {
            requestBuilder.dontAnimate();
        } else {
            requestBuilder.crossFade();
        }

        switch (config.getCacheStrategy()) {//缓存策略
            case 0:
                requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
                break;
            case 1:
                requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
                break;
            case 2:
                requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
                break;
            case 3:
                requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
                break;
        }

        if (config.getTransformation() != null) {//glide用它来改变图形的形状
            requestBuilder.transform(config.getTransformation());
        }

        //设置占位符
        if (config.getPlaceholder() != null) {
            requestBuilder.placeholder(config.getPlaceholder());
        } else if (config.getPlaceholderResId() != 0) {
            requestBuilder.placeholder(config.getPlaceholderResId());
        }

        if (config.getErrorPic() != 0)//设置错误的图片
            requestBuilder.error(config.getErrorPic());

        requestBuilder.skipMemoryCache(config.skipMemoryCache());

        requestBuilder.into(config.getImageView());
    }
 
开发者ID:BaoBaoJianqiang,项目名称:CustomListView,代码行数:60,代码来源:GlideImageLoaderStrategy.java

示例6: loadImage

import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
@Override
public void loadImage(Context ctx, GlideImageConfig config) {
    RequestManager manager;
    if (ctx instanceof Activity)//如果是activity则可以使用Activity的生命周期
        manager = Glide.with((Activity) ctx);
    else
        manager = Glide.with(ctx);

    DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
            .crossFade()
            .centerCrop();

    switch (config.getCacheStrategy()) {//缓存策略
        case 0:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
        case 1:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case 2:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
            break;
        case 3:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
            break;
    }

    if (config.getTransformation() != null) {//glide用它来改变图形的形状
        requestBuilder.transform(config.getTransformation());
    }


    if (config.getPlaceholder() != 0)//设置占位符
        requestBuilder.placeholder(config.getPlaceholder());

    if (config.getErrorPic() != 0)//设置错误的图片
        requestBuilder.error(config.getErrorPic());

    requestBuilder
            .into(config.getImageView());
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:42,代码来源:GlideImageLoaderStrategy.java

示例7: load

import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
@Override
public void load(Context context, GlideImageConfig config) {
    this.check(context, config);

    RequestManager manager = Glide.with(context);

    DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .crossFade()// 默认显示淡入淡出动画
            ;

    // 缓存策略
    switch (config.getCacheStrategy()) {
        case 0:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
        case 1:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case 2:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
            break;
        case 3:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
            break;
    }

    // 改变图形的形状
    if (config.getTransformation() != null) {
        requestBuilder.transform(config.getTransformation());
    }

    // 设置占位符
    if (config.getPlaceholder() != 0) {
        requestBuilder.placeholder(config.getPlaceholder());
    }

    // 设置错误的图片
    if (config.getError() != 0) {
        requestBuilder.error(config.getError());
    }

    requestBuilder.into(config.getImageView());
}
 
开发者ID:RockyQu,项目名称:MVVMFrames,代码行数:45,代码来源:GlideImageLoader.java

示例8: loadImage

import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
@Override
public void loadImage(Context ctx, GlideImageConfig config) {
    if (ctx == null) throw new IllegalStateException("Context is required");
    if (config == null) throw new IllegalStateException("GlideImageConfig is required");
    if (TextUtils.isEmpty(config.getUrl())) throw new IllegalStateException("Url is required");
    if (config.getImageView() == null) throw new IllegalStateException("Imageview is required");


    RequestManager manager;

    manager = Glide.with(ctx);//如果context是activity则自动使用Activity的生命周期

    DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
            .crossFade()
            .centerCrop();

    switch (config.getCacheStrategy()) {//缓存策略
        case 0:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
        case 1:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case 2:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
            break;
        case 3:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
            break;
    }

    if (config.getTransformation() != null) {//glide用它来改变图形的形状
        requestBuilder.transform(config.getTransformation());
    }


    if (config.getPlaceholder() != 0)//设置占位符
        requestBuilder.placeholder(config.getPlaceholder());

    if (config.getErrorPic() != 0)//设置错误的图片
        requestBuilder.error(config.getErrorPic());

    requestBuilder
            .into(config.getImageView());
}
 
开发者ID:yangxp108,项目名称:MVPArms_Fragment-fragment,代码行数:46,代码来源:GlideImageLoaderStrategy.java

示例9: loadImage

import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
/**
 * 根据GlideImageConfig中的配置进行加载图片
 *
 * @param ctx    context
 * @param config 图片加载
 */
@Override
public void loadImage(Context ctx, GlideImageConfig config) {
    if (ctx == null) throw new IllegalStateException("Context is required");
    if (config == null) throw new IllegalStateException("GlideImageConfig is required");
    if (TextUtils.isEmpty(config.getUrl())) throw new IllegalStateException("url is required");
    if (config.getImageView() == null) throw new IllegalStateException("imageview is required");


    RequestManager manager;

    manager = Glide.with(ctx);//如果context是activity则自动使用Activity的生命周期

    DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
            .crossFade()
            .centerCrop();

    switch (config.getCacheStrategy()) {//缓存策略
        case 0:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
        case 1:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case 2:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
            break;
        case 3:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
            break;
    }

    if (config.getTransformation() != null) {//glide用它来改变图形的形状
        requestBuilder.transform(config.getTransformation());
    }


    if (config.getPlaceholder() != 0)//设置占位符
        requestBuilder.placeholder(config.getPlaceholder());

    if (config.getErrorPic() != 0)//设置错误的图片
        requestBuilder.error(config.getErrorPic());

    requestBuilder
            .into(config.getImageView());
}
 
开发者ID:Wan7451,项目名称:mvparms,代码行数:52,代码来源:GlideImageLoaderStrategy.java

示例10: onBindViewHolder

import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder viewHolder, int position) {
    super.onBindViewHolder(viewHolder, position);
    NovelModel item = getItem(position);
    Novel novel = null;
    if (item instanceof Novel) {
        novel = (Novel) item;
    }
    if(viewHolder.mNovelTitleTextView != null) {
        viewHolder.mNovelTitleTextView.setText(item.getTitle());
        /*if(!mIsShowCoverImage) {
            viewHolder.mNovelTitleTextView.setTextColor(getContext().getResources().getColor(R.color.white_87_percent));
        }*/
    }

    if(viewHolder.mNovelInfo1TextView != null) {
        viewHolder.mNovelInfo1TextView.setText(item.getAuthor());
        /*if(!mIsShowCoverImage) {
            viewHolder.mNovelInfo1TextView.setTextColor(getContext().getResources().getColor(R.color.white_54_percent, null));
        }*/
    }

    if (viewHolder.mNovelInfo2TextView != null && novel != null && !TextUtils.isEmpty(novel.getCategory())) {
        viewHolder.mNovelInfo2TextView.setText(novel.getSummary());
        viewHolder.mNovelInfo2TextView.setVisibility(View.VISIBLE);
    }

    if(viewHolder.mBackCoverLayout != null && !(mIsNightMode && mGrayScale))
        viewHolder.mBackCoverLayout.setBackgroundColor(ColorUtils.getPreDefinedColorFromId(getContext().getResources(), item.getNovelId(), item.getTitle().length()));

    if(viewHolder.mNovelImageImageView != null) {

        DrawableRequestBuilder builder = Glide
                .with(getContext())
                .load(item.getCoverImage())
                .error(R.drawable.image_placeholder)
                .placeholder(R.drawable.image_placeholder);
        if (mIsNightMode && mGrayScale) {
            builder.transform(mGrayScaleTransformation);
        }
        builder.into(viewHolder.mNovelImageImageView);
    }
}
 
开发者ID:crysehillmes,项目名称:smoothnovelreader,代码行数:44,代码来源:NovelOnlineListAdapter.java


注:本文中的com.bumptech.glide.DrawableRequestBuilder.transform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。