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

项目:ReactNativeSignatureExample    文件:FrescoModule.java   
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();
}
项目:react-native-ibeacon-android    文件:FrescoModule.java   
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();
}
项目:react-native-box-loaders    文件:FrescoModule.java   
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();
}
项目:droidddle    文件:App.java   
@Override
    public void onCreate() {
        super.onCreate();
        sThis = this;
//        com.squareup.leakcanary.LeakCanary.install(this);
        initialize(this);
//        Glide.get(this).register(GlideUrl.class, InputStream.class,
//                new OkHttpUrlLoader.Factory(ApiFactory.getOkHttpClient(this)));
        ImagePipelineConfig config = OkHttpImagePipelineConfigFactory
                .newBuilder(this, ApiFactory.getOkHttpClient(this))
                .build();
        Fresco.initialize(this, config);

        if (true || OAuthUtils.haveToken(this)) {
//            Intent watchfaceLoader = new Intent();
//            watchfaceLoader.setClass(this, BucketWatchFaceLoader.class);
//            startService(BucketWatchFaceLoader.getServiceIntent(this));
            startService(FollowingCheckService.getServiceIntent(this));
        }
    }
项目:mdb-android-application    文件:MdbApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    this.applicationComponent = DaggerApplicationComponent.builder()
            .applicationModule(new ApplicationModule(this))
            .networkModule(new NetworkModule())
            .build();
    applicationComponent.inject(this);

    Fresco.initialize(getApplicationContext(),
            OkHttpImagePipelineConfigFactory.newBuilder(getApplicationContext(), frescoOkHttpClient)
                    .setDownsampleEnabled(true)
                    .build());
}
项目:AndroidGeek    文件:App.java   
@Override
public void onCreate() {
    super.onCreate();
    single = this;

    // 配置Fresco
    ImagePipelineConfig frescoConfig = OkHttpImagePipelineConfigFactory.newBuilder(this, getHttpClient())
            .build();
    Fresco.initialize(this, frescoConfig);
}
项目:meiShi    文件:ImagePipelineConfigFactory.java   
/**
 * Creates config using OkHttp as network backed.
 */
public static ImagePipelineConfig getOkHttpImagePipelineConfig(Context context,OkHttpClient okHttpClient) {
    if (sOkHttpImagePipelineConfig == null) {
        ImagePipelineConfig.Builder configBuilder =
                OkHttpImagePipelineConfigFactory.newBuilder(context, okHttpClient);
        configureCaches(configBuilder, context);
        configureLoggingListeners(configBuilder);
        sOkHttpImagePipelineConfig = configBuilder.build();
    }
    return sOkHttpImagePipelineConfig;
}
项目:tongnews    文件:MApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    DisplayMetrics dm = new DisplayMetrics();
    WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(dm);
    mScreenWidth = dm.widthPixels;
    mScreenHeight = dm.heightPixels;
    ImagePipelineConfig config = OkHttpImagePipelineConfigFactory
            .newBuilder(this, okHttpClient)
            .build();
    Fresco.initialize(this, config);
    MobclickAgent.openActivityDurationTrack(false);
}
项目:Li-MVPArms    文件:ConfigConstants.java   
/**
   * 初始化配置
   */
  private static ImagePipelineConfig configureCaches(Context context) {
      //内存配置
      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;
        }
    };

    //小图片的磁盘配置
      DiskCacheConfig diskSmallCacheConfig =  DiskCacheConfig.newBuilder()
              .setBaseDirectoryPath(context.getApplicationContext().getCacheDir())//缓存图片基路径
              .setBaseDirectoryName(IMAGE_PIPELINE_SMALL_CACHE_DIR)//文件夹名
//            .setCacheErrorLogger(cacheErrorLogger)//日志记录器用于日志错误的缓存。
//            .setCacheEventListener(cacheEventListener)//缓存事件侦听器。
//            .setDiskTrimmableRegistry(diskTrimmableRegistry)//类将包含一个注册表的缓存减少磁盘空间的环境。
              .setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)//默认缓存的最大大小。
              .setMaxCacheSizeOnLowDiskSpace(MAX_SMALL_DISK_LOW_CACHE_SIZE)//缓存的最大大小,使用设备时低磁盘空间。
              .setMaxCacheSizeOnVeryLowDiskSpace(MAX_SMALL_DISK_VERYLOW_CACHE_SIZE)//缓存的最大大小,当设备极低磁盘空间
//            .setVersion(version)
              .build();

    //默认图片的磁盘配置
      DiskCacheConfig diskCacheConfig =  DiskCacheConfig.newBuilder()
              .setBaseDirectoryPath(Environment.getExternalStorageDirectory().getAbsoluteFile())//缓存图片基路径
              .setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)//文件夹名
//            .setCacheErrorLogger(cacheErrorLogger)//日志记录器用于日志错误的缓存。
//            .setCacheEventListener(cacheEventListener)//缓存事件侦听器。
//            .setDiskTrimmableRegistry(diskTrimmableRegistry)//类将包含一个注册表的缓存减少磁盘空间的环境。
              .setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)//默认缓存的最大大小。
              .setMaxCacheSizeOnLowDiskSpace(MAX_DISK_CACHE_LOW_SIZE)//缓存的最大大小,使用设备时低磁盘空间。
              .setMaxCacheSizeOnVeryLowDiskSpace(MAX_DISK_CACHE_VERYLOW_SIZE)//缓存的最大大小,当设备极低磁盘空间
//            .setVersion(version)
              .build();

      //缓存图片配置
      ImagePipelineConfig.Builder configBuilder = ImagePipelineConfig.newBuilder(context)
//            .setAnimatedImageFactory(AnimatedImageFactory animatedImageFactory)//图片加载动画
              .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(progressiveJpegConfig)//渐进式JPEG图
//            .setRequestListeners(requestListeners)//图片请求监听
//            .setResizeAndRotateEnabledForNetwork(boolean resizeAndRotateEnabledForNetwork)//调整和旋转是否支持网络图片
              .setSmallImageDiskCacheConfig(diskSmallCacheConfig)//磁盘缓存配置(小图片,可选~三级缓存的小图优化缓存)
              ;   
//    return configBuilder.build();
      OkHttpClient okHttpClient = new OkHttpClient(); // build on your own
      ImagePipelineConfig config = OkHttpImagePipelineConfigFactory
              .newBuilder(context, okHttpClient)
              .setBitmapMemoryCacheParamsSupplier(mSupplierMemoryCacheParams)
              .setMainDiskCacheConfig(diskCacheConfig)
              .setSmallImageDiskCacheConfig(diskSmallCacheConfig)
              .build();
      return config;
  }
项目:android-mg-bootstrap    文件:MGImagesConfig.java   
public static void init(Context context, OkHttpClient client) {

        ImagePipelineConfig.Builder config;

        if (client != null) {

            config = OkHttpImagePipelineConfigFactory.newBuilder(context, client);

        } else {

            config = ImagePipelineConfig.newBuilder(context);
        }

        // Enable down-sampling.
        config.setDownsampleEnabled(true);
        config.setWebpSupportEnabled(true);

        // Setup caches.
        configureCaches(config, context);

        // Initialize fresco.
        Fresco.initialize(context, config.build());
    }