缓存

package com.example.zhou3.app;

import android.app.Application;
import android.os.Environment;

import com.facebook.cache.disk.DiskCacheConfig;
import com.facebook.common.internal.Supplier;
import com.facebook.common.util.ByteConstants;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.cache.MemoryCacheParams;
import com.facebook.imagepipeline.core.ImagePipelineConfig;

public class App extends Application {
private static int MAX_MEM = 30* ByteConstants.MB;
@Override
public void onCreate() {
super.onCreate();
DiskCacheConfig image = DiskCacheConfig.newBuilder(this)
.setBaseDirectoryName(“image”)
.setBaseDirectoryPath(Environment.getExternalStorageDirectory())
.build();
final MemoryCacheParams memoryCacheParams = new MemoryCacheParams(
MAX_MEM,
Integer.MAX_VALUE,
MAX_MEM,
Integer.MAX_VALUE,
Integer.MAX_VALUE);
Supplier supplier = new Supplier() {
@Override
public MemoryCacheParams get() {
return memoryCacheParams;
}
};
ImagePipelineConfig build = ImagePipelineConfig.newBuilder(this)
.setMainDiskCacheConfig(image)
.setBitmapMemoryCacheParamsSupplier(supplier)
.build();
Fresco.initialize(this,build);
}
}

展开阅读全文

没有更多推荐了,返回首页