Java 类com.facebook.imagepipeline.backends.okhttp3.OkHttpImagePipelineConfigFactory 实例源码

项目:PicKing    文件:MyApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .build();
    ImagePipelineConfig config = OkHttpImagePipelineConfigFactory.newBuilder(this, okHttpClient)
            .setMainDiskCacheConfig(getDiskCacheConfig())
            .setNetworkFetcher(new OkHttpNetworkFetcher(okHttpClient))
            .setDownsampleEnabled(true)
            .build();
    Fresco.initialize(this, config);

    Context context = getApplicationContext();
    String packageName = context.getPackageName();
    String processName = getProcessName(android.os.Process.myPid());
    CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(context);
    strategy.setUploadProcess(processName == null || processName.equals(packageName));
    CrashReport.initCrashReport(getApplicationContext(), "0a6e92fb70", false, strategy);

    registerActivityLifecycleCallbacks(ActivityLifecycleHelper.build());
}
项目:fast-list    文件:App.java   
@Override
public void onCreate() {
  super.onCreate();

  // di
  if (appComponent == null) {
    appComponent = DaggerAppComponent.builder()
        .appModule(new AppModule(this))
        .build();
  }
  getAppComponent().inject(this);

  // fresco
  ImagePipelineConfig imagePipelineConfig = OkHttpImagePipelineConfigFactory.newBuilder(this, mOkHttpClient)
      .setDownsampleEnabled(true)
      .build();
  Fresco.initialize(this, imagePipelineConfig);

  // logging
  if (BuildConfig.DEBUG) {
    Timber.plant(new ThreadAwareDebugTree());
  }
}
项目:richeditor    文件:AppManager.java   
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);
}
项目:RNLearn_Project1    文件:FrescoModule.java   
/**
 * Get the default Fresco configuration builder.
 * Allows adding of configuration options in addition to the default values.
 *
 * @return {@link ImagePipelineConfig.Builder} that has been initialized with default values
 */
public static ImagePipelineConfig.Builder getDefaultConfigBuilder(ReactContext context) {
  HashSet<RequestListener> requestListeners = new HashSet<>();
  requestListeners.add(new SystraceRequestListener());

  OkHttpClient client = OkHttpClientProvider.createClient();

  // make sure to forward cookies for any requests via the okHttpClient
  // so that image requests to endpoints that use cookies still work
  CookieJarContainer container = (CookieJarContainer) client.cookieJar();
  ForwardingCookieHandler handler = new ForwardingCookieHandler(context);
  container.setCookieJar(new JavaNetCookieJar(handler));

  return OkHttpImagePipelineConfigFactory
    .newBuilder(context.getApplicationContext(), client)
    .setNetworkFetcher(new ReactOkHttpNetworkFetcher(client))
    .setDownsampleEnabled(false)
    .setRequestListeners(requestListeners);
}
项目:RNLearn_Project1    文件:FrescoModule.java   
/**
 * Get the default Fresco configuration builder.
 * Allows adding of configuration options in addition to the default values.
 *
 * @return {@link ImagePipelineConfig.Builder} that has been initialized with default values
 */
public static ImagePipelineConfig.Builder getDefaultConfigBuilder(ReactContext context) {
  HashSet<RequestListener> requestListeners = new HashSet<>();
  requestListeners.add(new SystraceRequestListener());

  OkHttpClient client = OkHttpClientProvider.createClient();

  // make sure to forward cookies for any requests via the okHttpClient
  // so that image requests to endpoints that use cookies still work
  CookieJarContainer container = (CookieJarContainer) client.cookieJar();
  ForwardingCookieHandler handler = new ForwardingCookieHandler(context);
  container.setCookieJar(new JavaNetCookieJar(handler));

  return OkHttpImagePipelineConfigFactory
    .newBuilder(context.getApplicationContext(), client)
    .setNetworkFetcher(new ReactOkHttpNetworkFetcher(client))
    .setDownsampleEnabled(false)
    .setRequestListeners(requestListeners);
}
项目:zSMTH-Android    文件:SMTHApplication.java   
public void onCreate() {
  super.onCreate();
  SMTHApplication.context = getApplicationContext();

  // init IP lookup database
  geoDB = new GEODatabase(this);

  //        Set<RequestListener> requestListeners = new HashSet<>();
  //        requestListeners.add(new RequestLoggingListener());
  // init Fresco
  OkHttpClient httpClient = SMTHHelper.getInstance().mHttpClient;
  ImagePipelineConfig config = OkHttpImagePipelineConfigFactory.newBuilder(context, httpClient)
      //                .setRequestListeners(requestListeners)
      //                .setDownsampleEnabled(true)
      .build();
  Fresco.initialize(context, config);
  //        FLog.setMinimumLoggingLevel(FLog.VERBOSE);

  boolean bNightMode = Settings.getInstance().isNightMode();
  if (bNightMode) {
    AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
  } else {
    AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
  }
}
项目:DesignDemo    文件:MyApplication.java   
@Override
public void onCreate() {
    super.onCreate();

    // Flog是自定义Log
    if (BuildConfig.DEBUG) {
        Flog.DebugTree tree = new Flog.DebugTree();
        tree.setShowLine(false); // 是否打印类名和行号
        Flog.plant(tree);
    }

    OkHttpClient okHttpClient = new OkHttpClient();
    //配置Fresco
    ImagePipelineConfig config = OkHttpImagePipelineConfigFactory
            .newBuilder(this, okHttpClient)
            .build();
    Fresco.initialize(this, config);

    Glide.get(this).register(GlideUrl.class, InputStream.class,
            new OkHttpUrlLoader.Factory(okHttpClient));
}
项目:TLint    文件:MyApplication.java   
private void initFrescoConfig() {
    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);
    ImagePipelineConfig config = OkHttpImagePipelineConfigFactory.newBuilder(this, mOkHttpClient)
            .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
            .setBitmapMemoryCacheParamsSupplier(new Supplier<MemoryCacheParams>() {
                public MemoryCacheParams get() {
                    return bitmapCacheParams;
                }
            })
            .setMainDiskCacheConfig(
                    DiskCacheConfig.newBuilder(this).setMaxCacheSize(MAX_DISK_CACHE_SIZE).build())
            .setDownsampleEnabled(true)
            .build();
    Fresco.initialize(this, config);
}
项目:GitHub    文件:ImagePipelineConfigFactory.java   
/**
 * Creates config using OkHttp as network backed.
 */
public static ImagePipelineConfig getOkHttpImagePipelineConfig(Context context) {
  if (sOkHttpImagePipelineConfig == null) {
    OkHttpClient okHttpClient = new OkHttpClient.Builder()
        .addNetworkInterceptor(new StethoInterceptor())
        .build();
    ImagePipelineConfig.Builder configBuilder =
      OkHttpImagePipelineConfigFactory.newBuilder(context, okHttpClient);
    configureCaches(configBuilder, context);
    configureLoggingListeners(configBuilder);
    sOkHttpImagePipelineConfig = configBuilder.build();
  }
  return sOkHttpImagePipelineConfig;
}
项目:okuki    文件:NetworkModule.java   
public NetworkModule(Context context) {
    final HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);
    final OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
    bind(OkHttpClient.class).toInstance(client);
    final Moshi moshi = new Moshi.Builder().add(MoshiJsonAdapterFactory.create()).build();
    bind(Moshi.class).toInstance(moshi);
    final ImagePipelineConfig config = OkHttpImagePipelineConfigFactory.newBuilder(context, client).build();
    Fresco.initialize(context, config);
}
项目:MyImageUtil    文件:FrescoUtil.java   
/**
 * 初始化操作,在Application的onCreate方法中初始化,建议在子线程中进行
 *
 * 添加的依赖:
             compile 'com.facebook.fresco:fresco:0.12.0'
             // 在 API < 14 上的机器支持 WebP 时,需要添加
             compile 'com.facebook.fresco:animated-base-support:0.12.0'
             // 支持 GIF 动图,需要添加
             compile 'com.facebook.fresco:animated-gif:0.12.0'
             // 支持 WebP (静态图+动图),需要添加
             compile 'com.facebook.fresco:animated-webp:0.12.0'
             compile 'com.facebook.fresco:webpsupport:0.12.0'
             compile "com.facebook.fresco:imagepipeline-okhttp3:0.12.0+"
 * @param context
 * @param cacheSizeInM  磁盘缓存的大小,以M为单位

 */
public static void init(final Context context, int cacheSizeInM){
    isWWW = true;
    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();


    OkHttpClient okHttpClient= getAllPassClient(context);


    ImagePipelineConfig config = OkHttpImagePipelineConfigFactory.newBuilder(context,okHttpClient)
   // 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);

    WindowManager wm = (WindowManager) context.getSystemService(
            Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    screenWidth = display.getWidth() - dip2px(context,15);
}
项目:Ironman    文件:FrescoModule.java   
private static ImagePipelineConfig getDefaultConfig(Context context) {
  HashSet<RequestListener> requestListeners = new HashSet<>();
  requestListeners.add(new SystraceRequestListener());

  return OkHttpImagePipelineConfigFactory
    .newBuilder(context.getApplicationContext(), OkHttpClientProvider.getOkHttpClient())
    .setDownsampleEnabled(false)
    .setRequestListeners(requestListeners)
    .build();
}
项目:fresco    文件:ImagePipelineConfigFactory.java   
/**
 * Creates config using OkHttp as network backed.
 */
public static ImagePipelineConfig getOkHttpImagePipelineConfig(Context context) {
  if (sOkHttpImagePipelineConfig == null) {
    OkHttpClient okHttpClient = new OkHttpClient.Builder()
        .addNetworkInterceptor(new StethoInterceptor())
        .build();
    ImagePipelineConfig.Builder configBuilder =
      OkHttpImagePipelineConfigFactory.newBuilder(context, okHttpClient);
    configureCaches(configBuilder, context);
    configureLoggingListeners(configBuilder);
    sOkHttpImagePipelineConfig = configBuilder.build();
  }
  return sOkHttpImagePipelineConfig;
}
项目:GitHub    文件:ShowcaseApplication.java   
@Override
public void onCreate() {
  super.onCreate();
  FLog.setMinimumLoggingLevel(FLog.VERBOSE);
  Set<RequestListener> listeners = new HashSet<>();
  listeners.add(new RequestLoggingListener());

  OkHttpClient okHttpClient = new OkHttpClient.Builder()
      .addNetworkInterceptor(new StethoInterceptor())
      .build();

  ImagePipelineConfig imagePipelineConfig =
      OkHttpImagePipelineConfigFactory.newBuilder(this, okHttpClient)
          .setRequestListeners(listeners)
          .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
          .setImageDecoderConfig(CustomImageFormatConfigurator.createImageDecoderConfig(this))
          .experiment()
          .setMediaVariationsIndexEnabled(
              new Supplier<Boolean>() {
                @Override
                public Boolean get() {
                  return true;
                }
              })
          .experiment()
          .setBitmapPrepareToDraw(true, 0, Integer.MAX_VALUE, true)
          .experiment()
          .setSmartResizingEnabled(Suppliers.BOOLEAN_TRUE)
          .build();

  ImagePipelineConfig.getDefaultImageRequestConfig().setProgressiveRenderingEnabled(true);

  DraweeConfig.Builder draweeConfigBuilder = DraweeConfig.newBuilder();
  CustomImageFormatConfigurator.addCustomDrawableFactories(this, draweeConfigBuilder);

  draweeConfigBuilder.setDebugOverlayEnabledSupplier(
      DebugOverlaySupplierSingleton.getInstance(getApplicationContext()));

  Fresco.initialize(this, imagePipelineConfig, draweeConfigBuilder.build());

  final Context context = this;
  Stetho.initialize(
      Stetho.newInitializerBuilder(context)
          .enableDumpapp(
              new DumperPluginsProvider() {
                @Override
                public Iterable<DumperPlugin> get() {
                  return new Stetho.DefaultDumperPluginsBuilder(context)
                      .provide(new FrescoStethoPlugin())
                      .finish();
                }
              })
          .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(context))
          .build());
}
项目:androidtools    文件:ImagePipelineFactory.java   
/**
     * ImagePipeline配置
     *
     * @param context      context
     * @param okHttpClient okHttp客户端
     * @return ImagePipeline配置实例
     */
    private static ImagePipelineConfig configureCaches(Context context, OkHttpClient okHttpClient, String cachePath) {
        //内存配置
        final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
                ConfigConstants.MAX_MEMORY_CACHE_SIZE,// 内存缓存中总图片的最大大小,以字节为单位
                Integer.MAX_VALUE,// 内存缓存中图片的最大数量
                ConfigConstants.MAX_MEMORY_CACHE_SIZE,// 内存缓存中准备清除但尚未被删除的总图片的最大大小,以字节为单位
                Integer.MAX_VALUE,// 内存缓存中准备清除的总图片的最大数量
                Integer.MAX_VALUE);// 内存缓存中单个图片的最大大小
        //修改内存图片缓存数量,空间策略
        Supplier<MemoryCacheParams> mSupplierMemoryCacheParams = new Supplier<MemoryCacheParams>() {
            @Override
            public MemoryCacheParams get() {
                return bitmapCacheParams;
            }
        };
//        String cachePath = Environment.getExternalStorageDirectory().getAbsolutePath();//获得存储路径(SDcard)
        String file = "fresco";
        //小图片的磁盘配置
        DiskCacheConfig diskSmallCacheConfig = DiskCacheConfig.newBuilder(context)
                .setBaseDirectoryPath(new File(cachePath))//缓存图片基路径
                .setBaseDirectoryName(ConfigConstants.IMAGE_PIPELINE_SMALL_CACHE_DIR)//文件夹名
//            .setCacheErrorLogger(cacheErrorLogger)//日志记录器用于日志错误的缓存。
//            .setCacheEventListener(cacheEventListener)//缓存事件侦听器。
//            .setDiskTrimmableRegistry(diskTrimmableRegistry)//类将包含一个注册表的缓存减少磁盘空间的环境。
                .setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)//默认缓存的最大大小。
                .setMaxCacheSizeOnLowDiskSpace(ConfigConstants.MAX_SMALL_DISK_CACHE_LOW_SIZE)//缓存的最大大小,使用设备时低磁盘空间。
                .setMaxCacheSizeOnVeryLowDiskSpace(ConfigConstants.MAX_SMALL_DISK_CACHE_VERY_LOW_SIZE)//缓存的最大大小,当设备极低磁盘空间
//            .setVersion(version)
                .build();
        //默认图片的磁盘配置
        DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(context)
                .setBaseDirectoryPath(new File(cachePath))//缓存图片基路径
                .setBaseDirectoryName(ConfigConstants.IMAGE_PIPELINE_CACHE_DIR)//文件夹名
//            .setCacheErrorLogger(cacheErrorLogger)//日志记录器用于日志错误的缓存。
//            .setCacheEventListener(cacheEventListener)//缓存事件侦听器。
//            .setDiskTrimmableRegistry(diskTrimmableRegistry)//类将包含一个注册表的缓存减少磁盘空间的环境。
                .setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)//默认缓存的最大大小。
                .setMaxCacheSizeOnLowDiskSpace(ConfigConstants.MAX_DISK_CACHE_LOW_SIZE)//缓存的最大大小,使用设备时低磁盘空间。
                .setMaxCacheSizeOnVeryLowDiskSpace(ConfigConstants.MAX_DISK_CACHE_VERY_LOW_SIZE)//缓存的最大大小,当设备极低磁盘空间
//            .setVersion(version)
                .build();
        //缓存图片配置
        ImagePipelineConfig.Builder configBuilder = null;
        if (okHttpClient != null)
            configBuilder = OkHttpImagePipelineConfigFactory.newBuilder(context, okHttpClient);
        else
            configBuilder = ImagePipelineConfig.newBuilder(context);
//            .setAnimatedImageFactory(AnimatedImageFactory animatedImageFactory)//图片加载动画
        configBuilder.setBitmapMemoryCacheParamsSupplier(mSupplierMemoryCacheParams)//内存缓存配置(一级缓存,已解码的图片)
//            .setCacheKeyFactory(cacheKeyFactory)//缓存Key工厂
//            .setEncodedMemoryCacheParamsSupplier(encodedCacheParamsSupplier)//内存缓存和未解码的内存缓存的配置(二级缓存)
//            .setExecutorSupplier(executorSupplier)//线程池配置
//            .setImageCacheStatsTracker(imageCacheStatsTracker)//统计缓存的命中率
//            .setImageDecoder(ImageDecoder imageDecoder) //图片解码器配置
//            .setIsPrefetchEnabledSupplier(Supplier<Boolean> isPrefetchEnabledSupplier)//图片预览(缩略图,预加载图等)预加载到文件缓存
                .setMainDiskCacheConfig(diskCacheConfig)//磁盘缓存配置(总,三级缓存)
//            .setMemoryTrimmableRegistry(memoryTrimmableRegistry) //内存用量的缩减,有时我们可能会想缩小内存用量。比如应用中有其他数据需要占用内存,不得不把图片缓存清除或者减小 或者我们想检查看看手机是否已经内存不够了。
//            .setNetworkFetchProducer(networkFetchProducer)//自定的网络层配置:如OkHttp,Volley
//            .setPoolFactory(poolFactory)//线程池工厂配置
                .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())//渐进式JPEG图
//            .setRequestListeners(requestListeners)//图片请求监听
//            .setResizeAndRotateEnabledForNetwork(boolean resizeAndRotateEnabledForNetwork)//调整和旋转是否支持网络图片
                .setSmallImageDiskCacheConfig(diskSmallCacheConfig);//磁盘缓存配置(小图片,可选~三级缓存的小图优化缓存)
        return configBuilder.build();
    }
项目:RX_Demo    文件:ImagePipelineFactory.java   
/**
     * ImagePipeline配置
     *
     * @param context      context
     * @param okHttpClient okHttp客户端
     * @return ImagePipeline配置实例
     */
    private static ImagePipelineConfig configureCaches(Context context, OkHttpClient okHttpClient, String cachePath) {
        //内存配置
        final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
                ConfigConstants.MAX_MEMORY_CACHE_SIZE,// 内存缓存中总图片的最大大小,以字节为单位
                Integer.MAX_VALUE,// 内存缓存中图片的最大数量
                ConfigConstants.MAX_MEMORY_CACHE_SIZE,// 内存缓存中准备清除但尚未被删除的总图片的最大大小,以字节为单位
                Integer.MAX_VALUE,// 内存缓存中准备清除的总图片的最大数量
                Integer.MAX_VALUE);// 内存缓存中单个图片的最大大小
        //修改内存图片缓存数量,空间策略
        Supplier<MemoryCacheParams> mSupplierMemoryCacheParams = new Supplier<MemoryCacheParams>() {
            @Override
            public MemoryCacheParams get() {
                return bitmapCacheParams;
            }
        };
//        String cachePath = Environment.getExternalStorageDirectory().getAbsolutePath();//获得存储路径(SDcard)
        String file = "fresco";
        //小图片的磁盘配置
        DiskCacheConfig diskSmallCacheConfig = DiskCacheConfig.newBuilder(context)
                .setBaseDirectoryPath(new File(cachePath))//缓存图片基路径
                .setBaseDirectoryName(ConfigConstants.IMAGE_PIPELINE_SMALL_CACHE_DIR)//文件夹名
//            .setCacheErrorLogger(cacheErrorLogger)//日志记录器用于日志错误的缓存。
//            .setCacheEventListener(cacheEventListener)//缓存事件侦听器。
//            .setDiskTrimmableRegistry(diskTrimmableRegistry)//类将包含一个注册表的缓存减少磁盘空间的环境。
                .setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)//默认缓存的最大大小。
                .setMaxCacheSizeOnLowDiskSpace(ConfigConstants.MAX_SMALL_DISK_CACHE_LOW_SIZE)//缓存的最大大小,使用设备时低磁盘空间。
                .setMaxCacheSizeOnVeryLowDiskSpace(ConfigConstants.MAX_SMALL_DISK_CACHE_VERY_LOW_SIZE)//缓存的最大大小,当设备极低磁盘空间
//            .setVersion(version)
                .build();
        //默认图片的磁盘配置
        DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(context)
                .setBaseDirectoryPath(new File(cachePath))//缓存图片基路径
                .setBaseDirectoryName(ConfigConstants.IMAGE_PIPELINE_CACHE_DIR)//文件夹名
//            .setCacheErrorLogger(cacheErrorLogger)//日志记录器用于日志错误的缓存。
//            .setCacheEventListener(cacheEventListener)//缓存事件侦听器。
//            .setDiskTrimmableRegistry(diskTrimmableRegistry)//类将包含一个注册表的缓存减少磁盘空间的环境。
                .setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)//默认缓存的最大大小。
                .setMaxCacheSizeOnLowDiskSpace(ConfigConstants.MAX_DISK_CACHE_LOW_SIZE)//缓存的最大大小,使用设备时低磁盘空间。
                .setMaxCacheSizeOnVeryLowDiskSpace(ConfigConstants.MAX_DISK_CACHE_VERY_LOW_SIZE)//缓存的最大大小,当设备极低磁盘空间
//            .setVersion(version)
                .build();
        //缓存图片配置
        ImagePipelineConfig.Builder configBuilder = null;
        if (okHttpClient != null)
            configBuilder = OkHttpImagePipelineConfigFactory.newBuilder(context, okHttpClient);
        else
            configBuilder = ImagePipelineConfig.newBuilder(context);
//            .setAnimatedImageFactory(AnimatedImageFactory animatedImageFactory)//图片加载动画
        configBuilder.setBitmapMemoryCacheParamsSupplier(mSupplierMemoryCacheParams)//内存缓存配置(一级缓存,已解码的图片)
//            .setCacheKeyFactory(cacheKeyFactory)//缓存Key工厂
//            .setEncodedMemoryCacheParamsSupplier(encodedCacheParamsSupplier)//内存缓存和未解码的内存缓存的配置(二级缓存)
//            .setExecutorSupplier(executorSupplier)//线程池配置
//            .setImageCacheStatsTracker(imageCacheStatsTracker)//统计缓存的命中率
//            .setImageDecoder(ImageDecoder imageDecoder) //图片解码器配置
//            .setIsPrefetchEnabledSupplier(Supplier<Boolean> isPrefetchEnabledSupplier)//图片预览(缩略图,预加载图等)预加载到文件缓存
                .setMainDiskCacheConfig(diskCacheConfig)//磁盘缓存配置(总,三级缓存)
//            .setMemoryTrimmableRegistry(memoryTrimmableRegistry) //内存用量的缩减,有时我们可能会想缩小内存用量。比如应用中有其他数据需要占用内存,不得不把图片缓存清除或者减小 或者我们想检查看看手机是否已经内存不够了。
//            .setNetworkFetchProducer(networkFetchProducer)//自定的网络层配置:如OkHttp,Volley
//            .setPoolFactory(poolFactory)//线程池工厂配置
                .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())//渐进式JPEG图
//            .setRequestListeners(requestListeners)//图片请求监听
//            .setResizeAndRotateEnabledForNetwork(boolean resizeAndRotateEnabledForNetwork)//调整和旋转是否支持网络图片
                .setSmallImageDiskCacheConfig(diskSmallCacheConfig);//磁盘缓存配置(小图片,可选~三级缓存的小图优化缓存)
        return configBuilder.build();
    }
项目:androidgithub    文件:ImagePipelineFactory.java   
/**
     * ImagePipeline配置
     *
     * @param context      context
     * @param okHttpClient okHttp客户端
     * @return ImagePipeline配置实例
     */
    private static ImagePipelineConfig configureCaches(Context context, OkHttpClient okHttpClient, String cachePath) {
        //内存配置
        final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
                ConfigConstants.MAX_MEMORY_CACHE_SIZE,// 内存缓存中总图片的最大大小,以字节为单位
                Integer.MAX_VALUE,// 内存缓存中图片的最大数量
                ConfigConstants.MAX_MEMORY_CACHE_SIZE,// 内存缓存中准备清除但尚未被删除的总图片的最大大小,以字节为单位
                Integer.MAX_VALUE,// 内存缓存中准备清除的总图片的最大数量
                Integer.MAX_VALUE);// 内存缓存中单个图片的最大大小
        //修改内存图片缓存数量,空间策略
        Supplier<MemoryCacheParams> mSupplierMemoryCacheParams = new Supplier<MemoryCacheParams>() {
            @Override
            public MemoryCacheParams get() {
                return bitmapCacheParams;
            }
        };
//        String cachePath = Environment.getExternalStorageDirectory().getAbsolutePath();//获得存储路径(SDcard)
        String file = "fresco";
        //小图片的磁盘配置
        DiskCacheConfig diskSmallCacheConfig = DiskCacheConfig.newBuilder(context)
                .setBaseDirectoryPath(new File(cachePath))//缓存图片基路径
                .setBaseDirectoryName(ConfigConstants.IMAGE_PIPELINE_SMALL_CACHE_DIR)//文件夹名
//            .setCacheErrorLogger(cacheErrorLogger)//日志记录器用于日志错误的缓存。
//            .setCacheEventListener(cacheEventListener)//缓存事件侦听器。
//            .setDiskTrimmableRegistry(diskTrimmableRegistry)//类将包含一个注册表的缓存减少磁盘空间的环境。
                .setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)//默认缓存的最大大小。
                .setMaxCacheSizeOnLowDiskSpace(ConfigConstants.MAX_SMALL_DISK_CACHE_LOW_SIZE)//缓存的最大大小,使用设备时低磁盘空间。
                .setMaxCacheSizeOnVeryLowDiskSpace(ConfigConstants.MAX_SMALL_DISK_CACHE_VERY_LOW_SIZE)//缓存的最大大小,当设备极低磁盘空间
//            .setVersion(version)
                .build();
        //默认图片的磁盘配置
        DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(context)
                .setBaseDirectoryPath(new File(cachePath))//缓存图片基路径
                .setBaseDirectoryName(ConfigConstants.IMAGE_PIPELINE_CACHE_DIR)//文件夹名
//            .setCacheErrorLogger(cacheErrorLogger)//日志记录器用于日志错误的缓存。
//            .setCacheEventListener(cacheEventListener)//缓存事件侦听器。
//            .setDiskTrimmableRegistry(diskTrimmableRegistry)//类将包含一个注册表的缓存减少磁盘空间的环境。
                .setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)//默认缓存的最大大小。
                .setMaxCacheSizeOnLowDiskSpace(ConfigConstants.MAX_DISK_CACHE_LOW_SIZE)//缓存的最大大小,使用设备时低磁盘空间。
                .setMaxCacheSizeOnVeryLowDiskSpace(ConfigConstants.MAX_DISK_CACHE_VERY_LOW_SIZE)//缓存的最大大小,当设备极低磁盘空间
//            .setVersion(version)
                .build();
        //缓存图片配置
        ImagePipelineConfig.Builder configBuilder = null;
        if (okHttpClient != null)
            configBuilder = OkHttpImagePipelineConfigFactory.newBuilder(context, okHttpClient);
        else
            configBuilder = ImagePipelineConfig.newBuilder(context);
//            .setAnimatedImageFactory(AnimatedImageFactory animatedImageFactory)//图片加载动画
        configBuilder.setBitmapMemoryCacheParamsSupplier(mSupplierMemoryCacheParams)//内存缓存配置(一级缓存,已解码的图片)
//            .setCacheKeyFactory(cacheKeyFactory)//缓存Key工厂
//            .setEncodedMemoryCacheParamsSupplier(encodedCacheParamsSupplier)//内存缓存和未解码的内存缓存的配置(二级缓存)
//            .setExecutorSupplier(executorSupplier)//线程池配置
//            .setImageCacheStatsTracker(imageCacheStatsTracker)//统计缓存的命中率
//            .setImageDecoder(ImageDecoder imageDecoder) //图片解码器配置
//            .setIsPrefetchEnabledSupplier(Supplier<Boolean> isPrefetchEnabledSupplier)//图片预览(缩略图,预加载图等)预加载到文件缓存
                .setMainDiskCacheConfig(diskCacheConfig)//磁盘缓存配置(总,三级缓存)
//            .setMemoryTrimmableRegistry(memoryTrimmableRegistry) //内存用量的缩减,有时我们可能会想缩小内存用量。比如应用中有其他数据需要占用内存,不得不把图片缓存清除或者减小 或者我们想检查看看手机是否已经内存不够了。
//            .setNetworkFetchProducer(networkFetchProducer)//自定的网络层配置:如OkHttp,Volley
//            .setPoolFactory(poolFactory)//线程池工厂配置
                .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())//渐进式JPEG图
//            .setRequestListeners(requestListeners)//图片请求监听
//            .setResizeAndRotateEnabledForNetwork(boolean resizeAndRotateEnabledForNetwork)//调整和旋转是否支持网络图片
                .setSmallImageDiskCacheConfig(diskSmallCacheConfig);//磁盘缓存配置(小图片,可选~三级缓存的小图优化缓存)
        return configBuilder.build();
    }
项目:AppFirCloud    文件:ImagePipelineFactory.java   
/**
     * ImagePipeline配置
     *
     * @param context      context
     * @param okHttpClient okHttp客户端
     * @return ImagePipeline配置实例
     */
    private static ImagePipelineConfig configureCaches(Context context, OkHttpClient okHttpClient, String cachePath) {
        //内存配置
        final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
                ConfigConstants.MAX_MEMORY_CACHE_SIZE,// 内存缓存中总图片的最大大小,以字节为单位
                Integer.MAX_VALUE,// 内存缓存中图片的最大数量
                ConfigConstants.MAX_MEMORY_CACHE_SIZE,// 内存缓存中准备清除但尚未被删除的总图片的最大大小,以字节为单位
                Integer.MAX_VALUE,// 内存缓存中准备清除的总图片的最大数量
                Integer.MAX_VALUE);// 内存缓存中单个图片的最大大小
        //修改内存图片缓存数量,空间策略
        Supplier<MemoryCacheParams> mSupplierMemoryCacheParams = new Supplier<MemoryCacheParams>() {
            @Override
            public MemoryCacheParams get() {
                return bitmapCacheParams;
            }
        };
//        String cachePath = Environment.getExternalStorageDirectory().getAbsolutePath();//获得存储路径(SDcard)
        String file = "fresco";
        //小图片的磁盘配置
        DiskCacheConfig diskSmallCacheConfig = DiskCacheConfig.newBuilder(context)
                .setBaseDirectoryPath(new File(cachePath))//缓存图片基路径
                .setBaseDirectoryName(ConfigConstants.IMAGE_PIPELINE_SMALL_CACHE_DIR)//文件夹名
//            .setCacheErrorLogger(cacheErrorLogger)//日志记录器用于日志错误的缓存。
//            .setCacheEventListener(cacheEventListener)//缓存事件侦听器。
//            .setDiskTrimmableRegistry(diskTrimmableRegistry)//类将包含一个注册表的缓存减少磁盘空间的环境。
                .setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)//默认缓存的最大大小。
                .setMaxCacheSizeOnLowDiskSpace(ConfigConstants.MAX_SMALL_DISK_CACHE_LOW_SIZE)//缓存的最大大小,使用设备时低磁盘空间。
                .setMaxCacheSizeOnVeryLowDiskSpace(ConfigConstants.MAX_SMALL_DISK_CACHE_VERY_LOW_SIZE)//缓存的最大大小,当设备极低磁盘空间
//            .setVersion(version)
                .build();
        //默认图片的磁盘配置
        DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(context)
                .setBaseDirectoryPath(new File(cachePath))//缓存图片基路径
                .setBaseDirectoryName(ConfigConstants.IMAGE_PIPELINE_CACHE_DIR)//文件夹名
//            .setCacheErrorLogger(cacheErrorLogger)//日志记录器用于日志错误的缓存。
//            .setCacheEventListener(cacheEventListener)//缓存事件侦听器。
//            .setDiskTrimmableRegistry(diskTrimmableRegistry)//类将包含一个注册表的缓存减少磁盘空间的环境。
                .setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)//默认缓存的最大大小。
                .setMaxCacheSizeOnLowDiskSpace(ConfigConstants.MAX_DISK_CACHE_LOW_SIZE)//缓存的最大大小,使用设备时低磁盘空间。
                .setMaxCacheSizeOnVeryLowDiskSpace(ConfigConstants.MAX_DISK_CACHE_VERY_LOW_SIZE)//缓存的最大大小,当设备极低磁盘空间
//            .setVersion(version)
                .build();
        //缓存图片配置
        ImagePipelineConfig.Builder configBuilder = null;
        if (okHttpClient != null)
            configBuilder = OkHttpImagePipelineConfigFactory.newBuilder(context, okHttpClient);
        else
            configBuilder = ImagePipelineConfig.newBuilder(context);
//            .setAnimatedImageFactory(AnimatedImageFactory animatedImageFactory)//图片加载动画
        configBuilder.setBitmapMemoryCacheParamsSupplier(mSupplierMemoryCacheParams)//内存缓存配置(一级缓存,已解码的图片)
//            .setCacheKeyFactory(cacheKeyFactory)//缓存Key工厂
//            .setEncodedMemoryCacheParamsSupplier(encodedCacheParamsSupplier)//内存缓存和未解码的内存缓存的配置(二级缓存)
//            .setExecutorSupplier(executorSupplier)//线程池配置
//            .setImageCacheStatsTracker(imageCacheStatsTracker)//统计缓存的命中率
//            .setImageDecoder(ImageDecoder imageDecoder) //图片解码器配置
//            .setIsPrefetchEnabledSupplier(Supplier<Boolean> isPrefetchEnabledSupplier)//图片预览(缩略图,预加载图等)预加载到文件缓存
                .setMainDiskCacheConfig(diskCacheConfig)//磁盘缓存配置(总,三级缓存)
//            .setMemoryTrimmableRegistry(memoryTrimmableRegistry) //内存用量的缩减,有时我们可能会想缩小内存用量。比如应用中有其他数据需要占用内存,不得不把图片缓存清除或者减小 或者我们想检查看看手机是否已经内存不够了。
//            .setNetworkFetchProducer(networkFetchProducer)//自定的网络层配置:如OkHttp,Volley
//            .setPoolFactory(poolFactory)//线程池工厂配置
                .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())//渐进式JPEG图
//            .setRequestListeners(requestListeners)//图片请求监听
//            .setResizeAndRotateEnabledForNetwork(boolean resizeAndRotateEnabledForNetwork)//调整和旋转是否支持网络图片
                .setSmallImageDiskCacheConfig(diskSmallCacheConfig);//磁盘缓存配置(小图片,可选~三级缓存的小图优化缓存)
        return configBuilder.build();
    }
项目:NApply    文件:FrescoImageLoader.java   
public static void frescoInitialize(Context context){
    ImagePipelineConfig config = OkHttpImagePipelineConfigFactory.newBuilder(context,new OkHttpClient()).build();
    Fresco.initialize(context,config);
}
项目:fresco    文件:ShowcaseApplication.java   
@Override
public void onCreate() {
  super.onCreate();
  FLog.setMinimumLoggingLevel(FLog.VERBOSE);
  Set<RequestListener> listeners = new HashSet<>();
  listeners.add(new RequestLoggingListener());

  OkHttpClient okHttpClient = new OkHttpClient.Builder()
      .addNetworkInterceptor(new StethoInterceptor())
      .build();

  ImagePipelineConfig imagePipelineConfig =
      OkHttpImagePipelineConfigFactory.newBuilder(this, okHttpClient)
          .setRequestListeners(listeners)
          .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
          .setImageDecoderConfig(CustomImageFormatConfigurator.createImageDecoderConfig(this))
          .experiment()
          .setMediaVariationsIndexEnabled(
              new Supplier<Boolean>() {
                @Override
                public Boolean get() {
                  return true;
                }
              })
          .experiment()
          .setBitmapPrepareToDraw(true, 0, Integer.MAX_VALUE, true)
          .experiment()
          .setSmartResizingEnabled(Suppliers.BOOLEAN_TRUE)
          .build();

  ImagePipelineConfig.getDefaultImageRequestConfig().setProgressiveRenderingEnabled(true);

  DraweeConfig.Builder draweeConfigBuilder = DraweeConfig.newBuilder();
  CustomImageFormatConfigurator.addCustomDrawableFactories(this, draweeConfigBuilder);

  draweeConfigBuilder.setDebugOverlayEnabledSupplier(
      DebugOverlaySupplierSingleton.getInstance(getApplicationContext()));

  Fresco.initialize(this, imagePipelineConfig, draweeConfigBuilder.build());

  final Context context = this;
  Stetho.initialize(
      Stetho.newInitializerBuilder(context)
          .enableDumpapp(
              new DumperPluginsProvider() {
                @Override
                public Iterable<DumperPlugin> get() {
                  return new Stetho.DefaultDumperPluginsBuilder(context)
                      .provide(new FrescoStethoPlugin())
                      .finish();
                }
              })
          .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(context))
          .build());
}