當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。