Search in sources :

Example 11 with ImagePipelineConfig

use of com.facebook.imagepipeline.core.ImagePipelineConfig in project teaTime by ancfdy.

the class FrescoUtils method configureCaches.

/**
     * 初始化配置
     * @param context
     * @return
     */
private static ImagePipelineConfig configureCaches(Context context) {
    // 内存配置
    final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(// 内存缓存中总图片的最大大小,以字节为单位。
    FrescoUtils.MAX_MEMORY_CACHE_SIZE, // 内存缓存中图片的最大数量。
    Integer.MAX_VALUE, // 内存缓存中准备清除但尚未被删除的总图片的最大大小,以字节为单位。
    FrescoUtils.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(context).setBaseDirectoryPath(// 缓存图片基路径
    context.getApplicationContext().getCacheDir()).setBaseDirectoryName(// 文件夹名
    IMAGE_PIPELINE_SMALL_CACHE_DIR).setMaxCacheSize(// 默认缓存的最大大小。
    FrescoUtils.MAX_DISK_CACHE_SIZE).setMaxCacheSizeOnLowDiskSpace(// 缓存的最大大小,使用设备时低磁盘空间。
    MAX_SMALL_DISK_LOW_CACHE_SIZE).setMaxCacheSizeOnVeryLowDiskSpace(// 缓存的最大大小,当设备极低磁盘空间
    MAX_SMALL_DISK_VERYLOW_CACHE_SIZE).build();
    // 默认图片的磁盘配置
    DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(context).setBaseDirectoryPath(// 缓存图片基路径
    Environment.getExternalStorageDirectory().getAbsoluteFile()).setBaseDirectoryName(// 文件夹名
    IMAGE_PIPELINE_CACHE_DIR).setMaxCacheSize(// 默认缓存的最大大小。
    FrescoUtils.MAX_DISK_CACHE_SIZE).setMaxCacheSizeOnLowDiskSpace(// 缓存的最大大小,使用设备时低磁盘空间。
    MAX_DISK_CACHE_LOW_SIZE).setMaxCacheSizeOnVeryLowDiskSpace(// 缓存的最大大小,当设备极低磁盘空间
    MAX_DISK_CACHE_VERYLOW_SIZE).build();
    // 缓存图片配置
    ImagePipelineConfig.Builder configBuilder = ImagePipelineConfig.newBuilder(context).setBitmapMemoryCacheParamsSupplier(// 内存缓存配置(一级缓存,已解码的图片)
    mSupplierMemoryCacheParams).setMainDiskCacheConfig(// 磁盘缓存配置(总,三级缓存)
    diskCacheConfig).setSmallImageDiskCacheConfig(// 磁盘缓存配置(小图片,可选~三级缓存的小图优化缓存)
    diskSmallCacheConfig);
    return configBuilder.build();
}
Also used : DiskCacheConfig(com.facebook.cache.disk.DiskCacheConfig) ImagePipelineConfig(com.facebook.imagepipeline.core.ImagePipelineConfig) MemoryCacheParams(com.facebook.imagepipeline.cache.MemoryCacheParams) Supplier(com.facebook.common.internal.Supplier)

Example 12 with ImagePipelineConfig

use of com.facebook.imagepipeline.core.ImagePipelineConfig in project teaTime by ancfdy.

the class FrescoUtils method initConfig.

/**
     *  初始化配置,单例
     *  FrescoUtils.initConfig(context);
     *
     *  初始化配置的两种方式:
     * 在 Application 初始化时,在应用调用 setContentView() 之前,进行初始化:
     * Fresco.initialize(context);
     *
     * @param context
     * @return
     */
public static void initConfig(Context context) {
    ImagePipelineConfig initImagePipelineConfig = initImagePipelineConfig(context);
    Fresco.initialize(context, initImagePipelineConfig);
}
Also used : ImagePipelineConfig(com.facebook.imagepipeline.core.ImagePipelineConfig)

Example 13 with ImagePipelineConfig

use of com.facebook.imagepipeline.core.ImagePipelineConfig in project fresco by facebook.

the class ImagePipelineConfigFactory method getOkHttpImagePipelineConfig.

/**
   * 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;
}
Also used : OkHttpClient(okhttp3.OkHttpClient) ImagePipelineConfig(com.facebook.imagepipeline.core.ImagePipelineConfig) StethoInterceptor(com.facebook.stetho.okhttp3.StethoInterceptor)

Example 14 with ImagePipelineConfig

use of com.facebook.imagepipeline.core.ImagePipelineConfig in project fresco by facebook.

the class DemoApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    FLog.setMinimumLoggingLevel(FLog.VERBOSE);
    Set<RequestListener> listeners = new HashSet<>();
    listeners.add(new RequestLoggingListener());
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this).setRequestListeners(listeners).build();
    DraweeConfig draweeConfig = DraweeConfig.newBuilder().setDrawDebugOverlay(DebugOverlayHelper.isDebugOverlayEnabled(this)).build();
    Fresco.initialize(this, config, draweeConfig);
}
Also used : RequestListener(com.facebook.imagepipeline.listener.RequestListener) ImagePipelineConfig(com.facebook.imagepipeline.core.ImagePipelineConfig) RequestLoggingListener(com.facebook.imagepipeline.listener.RequestLoggingListener) DraweeConfig(com.facebook.drawee.backends.pipeline.DraweeConfig) HashSet(java.util.HashSet)

Example 15 with ImagePipelineConfig

use of com.facebook.imagepipeline.core.ImagePipelineConfig in project fresco by facebook.

the class ZoomableApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    FLog.setMinimumLoggingLevel(FLog.VERBOSE);
    Set<RequestListener> listeners = new HashSet<>();
    listeners.add(new RequestLoggingListener());
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this).setRequestListeners(listeners).build();
    Fresco.initialize(this, config);
}
Also used : RequestListener(com.facebook.imagepipeline.listener.RequestListener) ImagePipelineConfig(com.facebook.imagepipeline.core.ImagePipelineConfig) RequestLoggingListener(com.facebook.imagepipeline.listener.RequestLoggingListener) HashSet(java.util.HashSet)

Aggregations

ImagePipelineConfig (com.facebook.imagepipeline.core.ImagePipelineConfig)18 RequestListener (com.facebook.imagepipeline.listener.RequestListener)7 RequestLoggingListener (com.facebook.imagepipeline.listener.RequestLoggingListener)7 HashSet (java.util.HashSet)7 DiskCacheConfig (com.facebook.cache.disk.DiskCacheConfig)5 Supplier (com.facebook.common.internal.Supplier)5 MemoryCacheParams (com.facebook.imagepipeline.cache.MemoryCacheParams)4 DraweeConfig (com.facebook.drawee.backends.pipeline.DraweeConfig)3 File (java.io.File)2 AlarmManager (android.app.AlarmManager)1 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 ShowcaseMediaIdExtractor (com.facebook.fresco.samples.showcase.imagepipeline.ShowcaseMediaIdExtractor)1 StethoInterceptor (com.facebook.stetho.okhttp3.StethoInterceptor)1 AndroidMessenger (im.actor.core.AndroidMessenger)1 ApiConfiguration (im.actor.core.ApiConfiguration)1 ConfigurationBuilder (im.actor.core.ConfigurationBuilder)1 Runtime (im.actor.runtime.Runtime)1 ActorPushManager (im.actor.sdk.core.ActorPushManager)1 AndroidCallProvider (im.actor.sdk.core.AndroidCallProvider)1