Android的 - 如何从壁画磁盘高速缓存镜像文件?壁画、磁盘、镜像文件、高速缓存

2023-09-05 03:56:13 作者:つ唯恐天下不乱丶

我使用的是壁画库。

我找不到任何相关信息的壁画文档中, 我怎样才能从壁画的磁盘缓存得到的图像文件?

I can't find any related info in the Fresco documentation, how can I get an image file from Fresco's disk cache?

推荐答案

您必须创建一个DiskCacheConfig,把它传递给ImagePipelineConfig然后初始化壁画与配置:

You will have to create a DiskCacheConfig, pass it to ImagePipelineConfig and then init Fresco with that config:

DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder().setBaseDirectoryPath("/sdcard/")
            .setBaseDirectoryName("v1")
            .setMaxCacheSize(100 * ByteConstants.MB)
            .setMaxCacheSizeOnLowDiskSpace(10 * ByteConstants.MB)
            .setMaxCacheSizeOnVeryLowDiskSpace(5 * ByteConstants.MB)
            .setVersion(1)
            .build();

    ImagePipelineConfig imagePipelineConfig = ImagePipelineConfig.newBuilder(context).setMainDiskCacheConfig(diskCacheConfig).build();

    Fresco.initialize(context, imagePipelineConfig);

然后壁画就知道是否应该获取来自网络或磁盘

Then Fresco will know whether it should fetch from network or disk

 
精彩推荐
图片推荐