本文整理汇总了Java中com.facebook.cache.disk.DiskCacheConfig类的典型用法代码示例。如果您正苦于以下问题:Java DiskCacheConfig类的具体用法?Java DiskCacheConfig怎么用?Java DiskCacheConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DiskCacheConfig类属于com.facebook.cache.disk包,在下文中一共展示了DiskCacheConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
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 (cache != null) {
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);
}
示例2: buildDiskStorageCache
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
public static DiskStorageCache buildDiskStorageCache(
DiskCacheConfig diskCacheConfig,
DiskStorage diskStorage,
Executor executorForBackgroundInit) {
DiskStorageCache.Params params = new DiskStorageCache.Params(
diskCacheConfig.getMinimumSizeLimit(),
diskCacheConfig.getLowDiskSpaceSizeLimit(),
diskCacheConfig.getDefaultSizeLimit());
return new DiskStorageCache(
diskStorage,
diskCacheConfig.getEntryEvictionComparatorSupplier(),
params,
diskCacheConfig.getCacheEventListener(),
diskCacheConfig.getCacheErrorLogger(),
diskCacheConfig.getDiskTrimmableRegistry(),
diskCacheConfig.getContext(),
executorForBackgroundInit,
diskCacheConfig.getIndexPopulateAtStartupEnabled());
}
示例3: configureCaches
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
/**
* Configures disk and memory cache not to exceed common limits
*/
private static void configureCaches(ImagePipelineConfig.Builder configBuilder, Context context) {
final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
Integer.MAX_VALUE, // Max entries in the cache
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue
Integer.MAX_VALUE, // Max length of eviction queue
Integer.MAX_VALUE); // Max cache entry size
configBuilder
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
public MemoryCacheParams get() {
return bitmapCacheParams;
}
})
.setMainDiskCacheConfig(DiskCacheConfig.newBuilder(context)
.setBaseDirectoryPath(getExternalCacheDir(context))
.setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
.setMaxCacheSize(MAX_DISK_CACHE_SIZE)
.build());
}
示例4: init
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
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);
}
示例5: configureCaches
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
/**
* Configures disk and memory cache not to exceed common limits
*/
private static void configureCaches(
ImagePipelineConfig.Builder configBuilder,
Context context) {
final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
Integer.MAX_VALUE, // Max entries in the cache
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue
Integer.MAX_VALUE, // Max length of eviction queue
Integer.MAX_VALUE); // Max cache entry size
configBuilder
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
public MemoryCacheParams get() {
return bitmapCacheParams;
}
})
.setMainDiskCacheConfig(
DiskCacheConfig.newBuilder(context)
.setBaseDirectoryPath(context.getApplicationContext().getCacheDir())
.setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
.setMaxCacheSize(MAX_DISK_CACHE_SIZE)
.build());
}
示例6: init
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
/**
* 初始化
*/
public static void init(@NonNull Application application) {
DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(application)
.setBaseDirectoryName(CACHE_DIR_NAME)
.setBaseDirectoryPath(CacheUtil.getCacheDirectory(application, null))
.build();
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(application)
.setResizeAndRotateEnabledForNetwork(true)
.setDownsampleEnabled(true)
.setBitmapMemoryCacheParamsSupplier(new MemoryCacheParamsSupplier(
(ActivityManager) application.getSystemService(Context.ACTIVITY_SERVICE))) // 内存缓存配置
.setMainDiskCacheConfig(diskCacheConfig) // 磁盘缓存配置
.setCacheKeyFactory(DefaultCacheKeyFactory.getInstance()) // 自定义缓存key
.build();
Fresco.initialize(application, config);
}
示例7: FrescoInit
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
private void FrescoInit() {
DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(this)
.setMaxCacheSize(40 * ByteConstants.MB)
.setBaseDirectoryPathSupplier(new Supplier<File>() {
@Override
public File get() {
return getCacheDir();
}
})
.build();
final FrescoCacheParams bitmapCacheParams = new FrescoCacheParams(activityManager);
//Set<RequestListener> listeners = new HashSet<>();
ImagePipelineConfig imagePipelineConfig = OkHttpImagePipelineConfigFactory.newBuilder(this, RetrofitClient.getInstance().getOkHttpClient())
.setMainDiskCacheConfig(diskCacheConfig)
.setBitmapMemoryCacheParamsSupplier(bitmapCacheParams)
.setDownsampleEnabled(true)
.build();
Fresco.initialize(this, imagePipelineConfig);
}
示例8: getDefaultConfig
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
private static ImagePipelineConfig getDefaultConfig(
Context context,
@Nullable RequestListener listener,
@Nullable DiskCacheConfig diskCacheConfig) {
HashSet<RequestListener> requestListeners = new HashSet<>();
requestListeners.add(new SystraceRequestListener());
if (listener != null) {
requestListeners.add(listener);
}
OkHttpClient okHttpClient = OkHttpClientProvider.getOkHttpClient();
ImagePipelineConfig.Builder builder =
OkHttpImagePipelineConfigFactory.newBuilder(context.getApplicationContext(), okHttpClient);
builder
.setDownsampleEnabled(false)
.setRequestListeners(requestListeners);
if (diskCacheConfig != null) {
builder.setMainDiskCacheConfig(diskCacheConfig);
}
return builder.build();
}
示例9: configureCaches
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
/**
* Configures disk and memory cache not to exceed common limits
*/
private static void configureCaches(ImagePipelineConfig.Builder configBuilder, Context context) {
final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
Integer.MAX_VALUE, // Max entries in the cache
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue
Integer.MAX_VALUE, // Max length of eviction queue
Integer.MAX_VALUE); // Max cache entry size
configBuilder
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
public MemoryCacheParams get() {
return bitmapCacheParams;
}
})
.setMainDiskCacheConfig(DiskCacheConfig.newBuilder(context)
.setBaseDirectoryPath(getExternalCacheDir(context))
.setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
.setMaxCacheSize(MAX_DISK_CACHE_SIZE)
.build());
}
示例10: onCreate
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder()
.setBaseDirectoryPath(new File(Environment.getExternalStorageDirectory().getAbsoluteFile(), "Medlinker Pictures"))
.setBaseDirectoryName("fresco")
.setMaxCacheSize(Runtime.getRuntime().maxMemory() / 8)
.build();
ImagePipelineConfig imagePipelineConfig = ImagePipelineConfig.newBuilder(this)
.setMainDiskCacheConfig(diskCacheConfig)
.setDownsampleEnabled(true)
.build();
Fresco.initialize(this, imagePipelineConfig);
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, options));
}
示例11: init
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
/**
* 初始化操作,建议在子线程中进行
* 添加的依赖:
* compile 'com.facebook.fresco:fresco:0.10.0+'
compile 'com.facebook.fresco:animated-webp:0.10.0'
compile 'com.facebook.fresco:animated-gif:0.10.0'
* @param context
* @param cacheSizeInM 磁盘缓存的大小,以M为单位
*/
public static void init(final Context context,int cacheSizeInM){
DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(context)
.setMaxCacheSize(cacheSizeInM*1024*1024)
.setBaseDirectoryName(PHOTO_FRESCO)
.setBaseDirectoryPathSupplier(new Supplier<File>() {
@Override
public File get() {
return context.getCacheDir();
}
})
.build();
MyImageCacheStatsTracker imageCacheStatsTracker = new MyImageCacheStatsTracker();
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(context)
.setMainDiskCacheConfig(diskCacheConfig)
.setImageCacheStatsTracker(imageCacheStatsTracker)
.setDownsampleEnabled(true)//Downsampling,它处理图片的速度比常规的裁剪更快,
// 并且同时支持PNG,JPG以及WEP格式的图片,非常强大,与ResizeOptions配合使用
.setBitmapsConfig(Bitmap.Config.RGB_565)
.build();
Fresco.initialize(context, config);
}
示例12: getImagePipelineConfig
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
public static ImagePipelineConfig getImagePipelineConfig(Context context) {
if (sImagePipelineConfig == null) {
sImagePipelineConfig = ImagePipelineConfig.newBuilder(context)
.setMainDiskCacheConfig(DiskCacheConfig.newBuilder(context)
.setMaxCacheSize(ConfigConstants.MAX_CACHE_DISK_SIZE)
.build())
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
@Override
public MemoryCacheParams get() {
return new MemoryCacheParams(ConfigConstants.MAX_CACHE_MEMORY_SIZE,
Integer.MAX_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE);
}
}
)
.build();
}
return sImagePipelineConfig;
}
示例13: configureCaches
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
/**
* Configures disk and memory cache not to exceed common limits
*/
private static void configureCaches(
ImagePipelineConfig.Builder configBuilder,
Context context) {
final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
Integer.MAX_VALUE, // Max entries in the cache
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue
Integer.MAX_VALUE, // Max length of eviction queue
Integer.MAX_VALUE); // Max cache entry size
configBuilder
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
public MemoryCacheParams get() {
return bitmapCacheParams;
}
})
.setMainDiskCacheConfig(
DiskCacheConfig.newBuilder(context)
.setBaseDirectoryPath(context.getApplicationContext().getCacheDir())
.setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
.setMaxCacheSize(MAX_DISK_CACHE_SIZE)
.build());
}
示例14: onCreate
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
applicationContext = this;
/**
* 设置 Fresco 图片缓存的路径
*/
DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(getApplicationContext())
.setBaseDirectoryPath(getOwnCacheDirectory(this, APP_CACHE_PATH))
.build();
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(getApplicationContext())
.setMainDiskCacheConfig(diskCacheConfig)
.setSmallImageDiskCacheConfig(diskCacheConfig)
.build();
//初始化 Fresco 图片缓存库
Fresco.initialize(this, config);
//初始化日志输出工具
JLog.initialize(BuildConfig.LOG_DEBUG);
}
示例15: init
import com.facebook.cache.disk.DiskCacheConfig; //导入依赖的package包/类
/**
* 初始化操作,建议在子线程中进行
* 添加的依赖:
* compile 'com.facebook.fresco:fresco:0.10.0+'
compile 'com.facebook.fresco:animated-webp:0.10.0'
compile 'com.facebook.fresco:animated-gif:0.10.0'
* @param context
* @param cacheSizeInM 磁盘缓存的大小,以M为单位
*/
public static void init(final Context context,int cacheSizeInM){
DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(context)
.setMaxCacheSize(cacheSizeInM*1024*1024)
.setBaseDirectoryName(PHOTO_FRESCO)
.setBaseDirectoryPathSupplier(new Supplier<File>() {
@Override
public File get() {
return context.getCacheDir();
}
})
.build();
MyImageCacheStatsTracker imageCacheStatsTracker = new MyImageCacheStatsTracker();
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(context)
.setMainDiskCacheConfig(diskCacheConfig)
.setImageCacheStatsTracker(imageCacheStatsTracker)
.setDownsampleEnabled(true)//Downsampling,它处理图片的速度比常规的裁剪更快,
// 并且同时支持PNG,JPG以及WEP格式的图片,非常强大,与ResizeOptions配合使用
.setBitmapsConfig(Bitmap.Config.RGB_565)
.build();
Fresco.initialize(context, config);
}