当前位置: 首页>>代码示例>>Java>>正文


Java DiskCacheConfig类代码示例

本文整理汇总了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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:BoxingFrescoLoader.java

示例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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:DiskStorageCacheFactory.java

示例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());
}
 
开发者ID:Elbehiry,项目名称:Viajes,代码行数:24,代码来源:ImagePipelineConfigFactory.java

示例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);
}
 
开发者ID:Bilibili,项目名称:boxing,代码行数:22,代码来源:BoxingFrescoLoader.java

示例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());
}
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:27,代码来源:ImagePipelineConfigFactory.java

示例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);
}
 
开发者ID:senierr,项目名称:ModuleFrame,代码行数:19,代码来源:FrescoUtil.java

示例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);
}
 
开发者ID:nowandfurure,项目名称:richeditor,代码行数:21,代码来源:AppManager.java

示例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();
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:25,代码来源:FrescoModule.java

示例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());
}
 
开发者ID:LegendKe,项目名称:MyTravelingDiary,代码行数:24,代码来源:ImagePipelineConfigFactory.java

示例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));
}
 
开发者ID:LightSun,项目名称:android-photo-picker,代码行数:17,代码来源:MainActivity.java

示例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);
}
 
开发者ID:glassLake,项目名称:fastDev,代码行数:33,代码来源:FrescoUtils.java

示例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;
}
 
开发者ID:zhouruikevin,项目名称:ImageLoadPK,代码行数:23,代码来源:FrescoConfigFactory.java

示例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());
}
 
开发者ID:jiang111,项目名称:ZhiHu-TopAnswer,代码行数:27,代码来源:ImagePipelineConfigFactory.java

示例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);
}
 
开发者ID:Freelander,项目名称:Elephant,代码行数:22,代码来源:Elephant.java

示例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);
}
 
开发者ID:glassLake,项目名称:FrescoUtlis,代码行数:33,代码来源:FrescoUtils.java


注:本文中的com.facebook.cache.disk.DiskCacheConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。