相关疑难解决方法(0)

使用Glide预加载多个图像

我们正在尝试将图像预加载到缓存中以便以后加载它们(图像位于应用程序的Asset文件夹中)

我们尝试了什么:

Glide.with(this)
    .load(pictureUri)
    .diskCacheStrategy(DiskCacheStrategy.ALL);

Glide.with(this)
    .load(picture_uri)
    .diskCacheStrategy(DiskCacheStrategy.ALL)
    .preload();
Run Code Online (Sandbox Code Playgroud)

问题:只有当我们尝试加载/显示图像时才会缓存图像:必须先将它们加载到内存中,以便它们看起来更快.

Glide.with(this)
    .load(picture_uri)
    .into(imageView);
Run Code Online (Sandbox Code Playgroud)

我们还尝试使用GlideModule来增加CacheMemory大小:

public class GlideModule implements com.bumptech.glide.module.GlideModule {
    @Override
    public void applyOptions(Context context, GlideBuilder
        builder.setMemoryCache(new LruResourceCache(100000));
    }

    @Override
    public void registerComponents(Context context, Glide glide) {
    }
}
Run Code Online (Sandbox Code Playgroud)

在清单中:

 <meta-data android:name=".GlideModule" android:value="GlideModule"/>
Run Code Online (Sandbox Code Playgroud)

到目前为止没有任何工作.任何的想法?


我们尝试使用不可见的1 dp imageView,但结果是一样的:

for(Drawing drawing: getDrawingsForTab(tab)){

    Glide.with(this)
            .load(drawing.getImage().toUri())
            .dontAnimate()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .into(mPreloadCacheIv);

    for(Picture picture : getPictures()){

        Glide.with(this)
                .load(picture.getPicture().toUri())
                .dontAnimate()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(mPreloadCacheIv);
    }
}
Run Code Online (Sandbox Code Playgroud)

java android image android-glide

31
推荐指数
3
解决办法
2万
查看次数

标签 统计

android ×1

android-glide ×1

image ×1

java ×1