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


Java DrawableRequestBuilder.diskCacheStrategy方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例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())
            .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

示例6: 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


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