Java 类com.facebook.imagepipeline.core.ImagePipelineConfig 实例源码

项目:GitHub    文件:BoxingFrescoLoader.java   
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);
}
项目:GitHub    文件:Fresco.java   
/** Initializes Fresco with the specified config. */
public static void initialize(
    Context context,
    @Nullable ImagePipelineConfig imagePipelineConfig,
    @Nullable DraweeConfig draweeConfig) {
  if (sIsInitialized) {
    FLog.w(
        TAG,
        "Fresco has already been initialized! `Fresco.initialize(...)` should only be called " +
          "1 single time to avoid memory leaks!");
  } else {
    sIsInitialized = true;
  }
  // we should always use the application context to avoid memory leaks
  context = context.getApplicationContext();
  if (imagePipelineConfig == null) {
    ImagePipelineFactory.initialize(context);
  } else {
    ImagePipelineFactory.initialize(imagePipelineConfig);
  }
  initializeDrawee(context, draweeConfig);
}
项目:GitHub    文件:ScrollPerfApplication.java   
@Override
public void onCreate() {
  super.onCreate();
  final Config config = Config.load(this);
  ImagePipelineConfig.Builder imagePipelineConfigBuilder = ImagePipelineConfig.newBuilder(this)
      .setResizeAndRotateEnabledForNetwork(false)
      .setDownsampleEnabled(config.downsampling);
  if (WebpSupportStatus.sIsWebpSupportRequired) {
    imagePipelineConfigBuilder.experiment().setWebpSupportEnabled(config.webpSupportEnabled);
  }
  if (config.decodingThreadCount == 0) {
    imagePipelineConfigBuilder.setExecutorSupplier(
        new DefaultExecutorSupplier(Const.NUMBER_OF_PROCESSORS));
  } else {
    imagePipelineConfigBuilder.setExecutorSupplier(
        new ScrollPerfExecutorSupplier(Const.NUMBER_OF_PROCESSORS, config.decodingThreadCount));
  }
  imagePipelineConfigBuilder.experiment().setDecodeCancellationEnabled(config.decodeCancellation);
  DraweeConfig draweeConfig = DraweeConfig.newBuilder()
      .setDrawDebugOverlay(config.draweeOverlayEnabled)
      .build();
  Fresco.initialize(this, imagePipelineConfigBuilder.build(), draweeConfig);
}
项目:Viajes    文件:ImagePipelineConfigFactory.java   
/**
 * 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());
}
项目:boxing    文件:BoxingFrescoLoader.java   
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);
}
项目:jiansan-java    文件:App.java   
@Override
public void onCreate() {
    super.onCreate();

    app = this;

    // 存放所有activity的集合
    mActivityList = new ArrayList<>();

    // 渐进式图片
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
            .build();
    Fresco.initialize(this, config);

}
项目: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());
  }
}
项目:GongXianSheng    文件:ImagePipelineConfigFactory.java   
/**
 * 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());
}
项目:react-native-udesk    文件:ImagePipelineConfigFactory.java   
/**
 * 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());
}
项目:ModuleFrame    文件:FrescoUtil.java   
/**
 * 初始化
 */
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);
}
项目:Mobike    文件:MyApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    CrashReport.initCrashReport(getApplicationContext(), "e1a62089c6", false);
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
            .build();
    Fresco.initialize(this, config);
    SDKInitializer.initialize(this);
    Bmob.initialize(this, "b0cb494256d9b86fc931ca930a055b75");
    Logger.addLogAdapter(new AndroidLogAdapter(){
        @Override
        public boolean isLoggable(int priority, String tag) {
            return true;// TODO: 2017/6/5
        }
    });
    sInstance = this;
    initUser();
}
项目: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);
}
项目: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();
}
项目:MyTravelingDiary    文件:ImagePipelineConfigFactory.java   
/**
 * 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());
}
项目:android-photo-picker    文件:MainActivity.java   
@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));
}
项目:ChatUp    文件:ImagePipelineConfigFactory.java   
/**
 * 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());
}
项目: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();
}
项目:fastDev    文件:FrescoUtils.java   
/**
 * 初始化操作,建议在子线程中进行
 * 添加的依赖:
 *  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);
}
项目:FrescoCustomCacheKey    文件:App.java   
@Override
public void onCreate() {
    super.onCreate();

    OkHttpClient okHttpClient = new OkHttpClient();

    File sd = Environment.getExternalStorageDirectory();
    String image = sd.getPath() + "/imageLoad";
    //配置图片缓存目录
    File cacheDir = new File(image);
    if (!cacheDir.exists()) {
        Log.i("App", "path:" + cacheDir.getAbsolutePath());
    }
    //初始化Fresco,使用OkHttp3作为网络请求
    ImagePipelineConfig.Builder configBuilder = FrescoConfig
            .getConfigBuilder(getApplicationContext(), cacheDir, okHttpClient);
    Fresco.initialize(this, configBuilder.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();
}
项目:android-base    文件:FrescoUtils.java   
/**
 * initialize
 *
 * @param context context
 */
public static void initialize(Context context) {
    try {
        if (isInit)
            return;
        Class<?> clazz = Class.forName("com.facebook.imagepipeline.core.ImagePipelineConfig");
        if (clazz != null) {
            ImagePipelineConfig config = ImagePipelineConfig.newBuilder(context)
                    .setDownsampleEnabled(true)
                    .build();
            Fresco.initialize(context, config);
            isInit = true;
        }
    } catch (Exception e) {
    }
}
项目:ImitateNetEasyCloud    文件:NetEasyApplication.java   
private ImagePipelineConfig getConfigureCaches(Context context) {
    final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
            MAX_MEM,// 内存缓存中总图片的最大大小,以字节为单位。
            Integer.MAX_VALUE,// 内存缓存中图片的最大数量。
            MAX_MEM,// 内存缓存中准备清除但尚未被删除的总图片的最大大小,以字节为单位。
            Integer.MAX_VALUE,// 内存缓存中准备清除的总图片的最大数量。
            Integer.MAX_VALUE / 10);// 内存缓存中单个图片的最大大小。

    Supplier<MemoryCacheParams> mSupplierMemoryCacheParams = new Supplier<MemoryCacheParams>() {
        @Override
        public MemoryCacheParams get() {
            return bitmapCacheParams;
        }
    };
    ImagePipelineConfig.Builder builder = ImagePipelineConfig.newBuilder(context)
            .setDownsampleEnabled(true);
    builder.setBitmapMemoryCacheParamsSupplier(mSupplierMemoryCacheParams);
    return builder.build();
}
项目:APlayer    文件:APlayerApplication.java   
private void initUtil() {
    //初始化工具类
    DBManager.initialInstance(new DBOpenHelper(mContext));
    PermissionUtil.setContext(mContext);
    MediaStoreUtil.setContext(mContext);
    Util.setContext(mContext);
    ImageUriUtil.setContext(mContext);
    DiskCache.init(mContext);
    ColorUtil.setContext(mContext);
    PlayListUtil.setContext(mContext);
    final int cacheSize = (int)(Runtime.getRuntime().maxMemory() / 8);
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setBitmapMemoryCacheParamsSupplier(() -> new MemoryCacheParams(cacheSize, Integer.MAX_VALUE,cacheSize,Integer.MAX_VALUE, 2 * ByteConstants.MB))
            .setBitmapsConfig(Bitmap.Config.RGB_565)
            .setDownsampleEnabled(true)
            .build();
    Fresco.initialize(this,config);
}
项目:ImageLoadPK    文件:FrescoConfigFactory.java   
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;
}
项目:StudyApp    文件:App.java   
@Override
public void onCreate() {
    super.onCreate();

    init();

    //初始化KLog
    KLog.init(BuildConfig.LOG_DEBUG);
    // fresco图片库的初始化
    ImagePipelineConfig.Builder configBuilder = ImagePipelineConfig.newBuilder(this);
    ImagePipelineConfig imagePipelineConfig = configBuilder.build();
    Fresco.initialize(this, imagePipelineConfig);

    /**
     * 如果存在SD卡则将缓存写入SD卡,否则写入手机内存
     */
    if (getApplicationContext().getExternalCacheDir() != null && ExistSDCard()) {
        cacheDir = getApplicationContext().getExternalCacheDir().toString();
    } else {
        cacheDir = getApplicationContext().getCacheDir().toString();
    }
}
项目:ZhiHu-TopAnswer    文件:ImagePipelineConfigFactory.java   
/**
 * 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());
}
项目:WhiteRead    文件:FrescoConfigFactory.java   
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;
}
项目:Elephant    文件:Elephant.java   
@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);
}
项目:FrescoUtlis    文件:FrescoUtils.java   
/**
 * 初始化操作,建议在子线程中进行
 * 添加的依赖:
 *  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);
}
项目: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);
  }
}
项目: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));
        }
    }
项目:meiShi    文件:ImagePipelineConfigFactory.java   
/**
 * Configures disk and memory cache not to exceed common limits
 */
private static void configureCaches(
        ImagePipelineConfig.Builder configBuilder,
        Context context) {
    FileUtils.createDirs(ConfigConstants.IMAGE_PIPELINE_CACHE_DIR);
    final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
            ConfigConstants.MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
            Integer.MAX_VALUE,                     // Max entries in the cache
            ConfigConstants.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(FileUtils.createDirs(ConfigConstants.IMAGE_PIPELINE_BASE_DIR))
                            .setBaseDirectoryName(ConfigConstants.IMAGE_PIPELINE_CACHE_DIR)
                            .setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)
                            .build());
}
项目: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);
}
项目:HaoCommon    文件:ImagePipelineConfigFactory.java   
/**
 * 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()
                            .setBaseDirectoryPath(getExternalCacheDir(context))
                            .setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
                            .setMaxCacheSize(MAX_DISK_CACHE_SIZE)
                            .build());
}
项目:fresco    文件:ImagePipelineConfigFactory.java   
/**
 * Configures disk and memory cache not to exceed common limits
 */
private static void configureCaches(
    ImagePipelineConfig.Builder configBuilder,
    Context context) {
  final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
      ConfigConstants.MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
      Integer.MAX_VALUE,                     // Max entries in the cache
      ConfigConstants.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(ConfigConstants.MAX_DISK_CACHE_SIZE)
              .build());
}
项目:fresco    文件:ScrollPerfApplication.java   
@Override
public void onCreate() {
  super.onCreate();
  final Config config = Config.load(this);
  ImagePipelineConfig.Builder imagePipelineConfigBuilder = ImagePipelineConfig.newBuilder(this)
      .setResizeAndRotateEnabledForNetwork(false)
      .setDownsampleEnabled(config.downsampling);
  if (WebpSupportStatus.sIsWebpSupportRequired) {
    imagePipelineConfigBuilder.experiment().setWebpSupportEnabled(config.webpSupportEnabled);
  }
  if (config.decodingThreadCount == 0) {
    imagePipelineConfigBuilder.setExecutorSupplier(
        new DefaultExecutorSupplier(Const.NUMBER_OF_PROCESSORS));
  } else {
    imagePipelineConfigBuilder.setExecutorSupplier(
        new ScrollPerfExecutorSupplier(Const.NUMBER_OF_PROCESSORS, config.decodingThreadCount));
  }
  imagePipelineConfigBuilder.experiment().setDecodeCancellationEnabled(config.decodeCancellation);
  DraweeConfig draweeConfig = DraweeConfig.newBuilder()
      .setDrawDebugOverlay(config.draweeOverlayEnabled)
      .build();
  Fresco.initialize(this, imagePipelineConfigBuilder.build(), draweeConfig);
}