use of com.facebook.cache.disk.DiskCacheConfig in project boxing by Bilibili.
the class BoxingFrescoLoader method init.
private void init(Context context) {
ImagePipelineConfig.Builder builder = ImagePipelineConfig.newBuilder(context).setDownsampleEnabled(true);
String cache = BoxingFileHelper.getCacheDir(context);
if (TextUtils.isEmpty(cache)) {
throw new IllegalStateException("the cache dir is null");
}
if (!TextUtils.isEmpty(cache)) {
DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(context).setBaseDirectoryPath(new File(cache)).setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR).setMaxCacheSize(MAX_DISK_CACHE_SIZE).setMaxCacheSizeOnLowDiskSpace(MAX_DISK_CACHE_LOW_SIZE).setMaxCacheSizeOnVeryLowDiskSpace(MAX_DISK_CACHE_VERYLOW_SIZE).build();
builder.setMainDiskCacheConfig(diskCacheConfig);
}
ImagePipelineConfig config = builder.build();
Fresco.initialize(context, config);
}
use of com.facebook.cache.disk.DiskCacheConfig in project osm-contributor by jawg.
the class OsmTemplateApplication method onCreate.
/*=========================================*/
/*---------------OVERRIDE------------------*/
/*=========================================*/
@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
}
Fabric.with(this, new Crashlytics());
// Init Stetho for debug purpose (database)
Stetho.initializeWithDefaults(this);
// Init Dagger
osmTemplateComponent = DaggerOsmTemplateComponent.builder().osmTemplateModule(new OsmTemplateModule(this)).build();
osmTemplateComponent.inject(this);
// Init Flickr object
StoreConfigManager configManager = new StoreConfigManager();
flickr = new Flickr(configManager.getFlickrApiKey(), configManager.getFlickrApiKeySecret(), new REST());
// Cache Disk for Fresco
DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(this).setBaseDirectoryPath(new File(Environment.getExternalStorageDirectory().getAbsoluteFile(), getPackageName())).setBaseDirectoryName("images").build();
// Cache Memory for Fresco
ImagePipelineConfig imagePipelineConfig = ImagePipelineConfig.newBuilder(this).setBitmapMemoryCacheParamsSupplier(new Supplier<MemoryCacheParams>() {
@Override
public MemoryCacheParams get() {
return new MemoryCacheParams(10485760, 100, 100, 100, 100);
}
}).setMainDiskCacheConfig(diskCacheConfig).build();
// Init Fresco
Fresco.initialize(this, imagePipelineConfig);
// Init event bus
EventBus bus = osmTemplateComponent.getEventBus();
bus.register(getOsmTemplateComponent().getLoginManager());
bus.register(getOsmTemplateComponent().getEditPoiManager());
bus.register(getOsmTemplateComponent().getPoiManager());
bus.register(getOsmTemplateComponent().getNoteManager());
bus.register(getOsmTemplateComponent().getSyncManager());
bus.register(getOsmTemplateComponent().getTypeManager());
bus.register(getOsmTemplateComponent().getPresetsManager());
bus.register(getOsmTemplateComponent().getGeocoder());
bus.register(getOsmTemplateComponent().getEditVectorialWayManager());
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean(getString(R.string.shared_prefs_preset_default), false)) {
editor.putBoolean(getString(R.string.shared_prefs_preset_default), true);
}
editor.apply();
MapboxAccountManager.start(this, BuildConfig.MAPBOX_TOKEN);
}
use of com.facebook.cache.disk.DiskCacheConfig in project fresco by facebook.
the class ImagePipelineFactory method getMainFileCache.
public FileCache getMainFileCache() {
if (mMainFileCache == null) {
DiskCacheConfig diskCacheConfig = mConfig.getMainDiskCacheConfig();
mMainFileCache = mConfig.getFileCacheFactory().get(diskCacheConfig);
}
return mMainFileCache;
}
use of com.facebook.cache.disk.DiskCacheConfig in project ride-read-android by Ride-Read.
the class FrescoApp method configureCaches.
/**
* 初始化配置
*/
private ImagePipelineConfig configureCaches(Context context) {
final MemoryCacheParams bitmapCacheParams = new // 内存缓存中总图片的最大大小,以字节为单位。
MemoryCacheParams(// 内存缓存中总图片的最大大小,以字节为单位。
50 * ByteConstants.MB, // 内存缓存中图片的最大数量。
500, // 内存缓存中准备清除但尚未被删除的总图片的最大大小,以字节为单位。
50 * ByteConstants.MB, // 内存缓存中准备清除的总图片的最大数量。
500, // 内存缓存中单个图片的最大大小。
5 * ByteConstants.MB);
// 修改内存图片缓存数量,空间策略(这个方式有点恶心)
// Supplier<MemoryCacheParams> mSupplierMemoryCacheParams = new Supplier<MemoryCacheParams>() {
// @Override
// public MemoryCacheParams get() {
// return bitmapCacheParams;
// }
// };
// 小图片的磁盘配置
DiskCacheConfig diskSmallCacheConfig = // 缓存图片基路径
DiskCacheConfig.newBuilder(this).setBaseDirectoryPath(new File(FRESCO_PATH)).setBaseDirectoryName(// 文件夹名
IMAGE_PIPELINE_SMALL_CACHE_DIR).setMaxCacheSize(// 默认缓存的最大大小。
MAX_SMALL_DISK_CACHE_SIZE).setMaxCacheSizeOnLowDiskSpace(// 缓存的最大大小,使用设备时低磁盘空间。
MAX_SMALL_DISK_LOW_CACHE_SIZE).setMaxCacheSizeOnVeryLowDiskSpace(// 缓存的最大大小,当设备极低磁盘空间
MAX_SMALL_DISK_VERYLOW_CACHE_SIZE).build();
// 默认图片的磁盘配置
DiskCacheConfig diskCacheConfig = // 缓存图片基路径
DiskCacheConfig.newBuilder(this).setBaseDirectoryPath(new File(FRESCO_PATH)).setBaseDirectoryName(// 文件夹名
IMAGE_PIPELINE_CACHE_DIR).setMaxCacheSize(// 默认缓存的最大大小。
MAX_DISK_CACHE_SIZE).setMaxCacheSizeOnLowDiskSpace(// 缓存的最大大小,使用设备时低磁盘空间。
MAX_DISK_CACHE_LOW_SIZE).setMaxCacheSizeOnVeryLowDiskSpace(// 缓存的最大大小,当设备极低磁盘空间
MAX_DISK_CACHE_VERYLOW_SIZE).build();
// 缓存图片配置
Supplier<MemoryCacheParams> bitmapCacheParamsSupplier = new Supplier<MemoryCacheParams>() {
@Override
public MemoryCacheParams get() {
return bitmapCacheParams;
}
};
ImagePipelineConfig.Builder configBuilder = ImagePipelineConfig.newBuilder(context).setBitmapMemoryCacheParamsSupplier(bitmapCacheParamsSupplier).setMainDiskCacheConfig(// 磁盘缓存配置(总,三级缓存)
diskCacheConfig).setSmallImageDiskCacheConfig(// 磁盘缓存配置(小图片,可选~三级缓存的小图优化缓存)
diskSmallCacheConfig);
return configBuilder.build();
}
Aggregations