Search in sources :

Example 6 with ImagePipelineConfig

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

the class UriApplication 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)

Example 7 with ImagePipelineConfig

use of com.facebook.imagepipeline.core.ImagePipelineConfig in project Rocket.Chat.Android by RocketChat.

the class RocketChatWidgets method initialize.

public static void initialize(Context context, OkHttpClient okHttpClient) {
    ImagePipelineConfig config = OkHttpImagePipelineConfigFactory.newBuilder(context, okHttpClient).setDownsampleEnabled(true).setImageDecoderConfig(ImageFormatConfigurator.createImageDecoderConfig()).build();
    DraweeConfig.Builder draweeConfigBuilder = DraweeConfig.newBuilder();
    ImageFormatConfigurator.addCustomDrawableFactories(draweeConfigBuilder);
    Fresco.initialize(context, config, draweeConfigBuilder.build());
    Fresco.getImagePipeline().clearCaches();
}
Also used : ImagePipelineConfig(com.facebook.imagepipeline.core.ImagePipelineConfig) DraweeConfig(com.facebook.drawee.backends.pipeline.DraweeConfig)

Example 8 with ImagePipelineConfig

use of com.facebook.imagepipeline.core.ImagePipelineConfig in project boxing by Bilibili.

the class BoxingFrescoLoader method init.

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);
}
Also used : DiskCacheConfig(com.facebook.cache.disk.DiskCacheConfig) ImagePipelineConfig(com.facebook.imagepipeline.core.ImagePipelineConfig) File(java.io.File)

Example 9 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 10 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)

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