@Test public void testCreatingRequestFromExistingRequest() { ImageRequest original = ImageRequestBuilder .newBuilderWithSource(Uri.parse("http://frescolib.org/image.jpg")) .setCacheChoice(ImageRequest.CacheChoice.SMALL) .setImageDecodeOptions(new ImageDecodeOptionsBuilder().build()) .setLocalThumbnailPreviewsEnabled(true) .setLowestPermittedRequestLevel(ImageRequest.RequestLevel.DISK_CACHE) .setMediaVariations(MediaVariations.forMediaId("A113")) .setPostprocessor(new BasePostprocessor() { @Override public String getName() { return super.getName(); } }) .setProgressiveRenderingEnabled(true) .setRequestListener(new RequestLoggingListener()) .setResizeOptions(new ResizeOptions(20, 20)) .setRotationOptions(RotationOptions.forceRotation(RotationOptions.ROTATE_90)) .setRequestPriority(Priority.HIGH) .build(); ImageRequest copy = ImageRequestBuilder.fromRequest(original).build(); assertThat(copy).isEqualTo(original); }
@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); }
@Override public void onCreate() { super.onCreate(); Set<RequestListener> requestListeners = new HashSet<>(); requestListeners.add(new RequestLoggingListener()); ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this) // other setters .setRequestListeners(requestListeners) .build(); Fresco.initialize(this, config); FLog.setMinimumLoggingLevel(FLog.VERBOSE); }
private void initialize() { mApplication = this; mContext = this.getApplicationContext(); mResources = this.getResources(); Builder builder = Logcat.newBuilder(); builder.logCatLogLevel(Logcat.SHOW_VERBOSE_LOG); // builder.logCatLogLevel(Logcat.NOT_SHOW_LOG); // Logcat.initialize(this, builder.build()); Logcat.initialize(this); if (IS_DEBUG_ACTIVITYLIFE) { mActivityLifecycle = new MyActivityLifecycle(); this.registerActivityLifecycleCallbacks(mActivityLifecycle); } // Set<RequestListener> requestListeners = new HashSet<>(); requestListeners.add(new RequestLoggingListener()); ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this) // other setters .setRequestListeners(requestListeners) //配置图片磁盘缓存 .setMainDiskCacheConfig(DiskCacheConfig.newBuilder(this) .setBaseDirectoryName("image") //父目录下的文件夹名 .setBaseDirectoryPath(StorageUtils.getAppCacheFile(this)) //保存父目录 .build()) .build(); Fresco.initialize(this, config); FLog.setMinimumLoggingLevel(FLog.DEBUG); try { CrashHandler crashHandler = CrashHandler.getInstance(); crashHandler.init(this, Config.CARSH_LOG_PATH); } catch (Exception e) { e.printStackTrace(); } }
/** * 初始化fresco */ private void initFresco() { Set<RequestListener> requestListeners = new HashSet<>(); requestListeners.add(new RequestLoggingListener()); ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this) .setBitmapsConfig(Bitmap.Config.ARGB_8888) .setDownsampleEnabled(true) .setNetworkFetcher(new OkHttpNetworkFetcher(new OkHttpClient())) .setRequestListeners(requestListeners) .build(); Fresco.initialize(this, config); }
private void initFresco() { final ImagePipelineConfig.Builder configBuilder = ImagePipelineConfig.newBuilder(this); File cacheDir = getExternalCacheDir(); if (cacheDir == null) { cacheDir = getCacheDir(); } final DiskCacheConfig.Builder mainDiskCacheConfigBuilder = DiskCacheConfig.newBuilder(this); mainDiskCacheConfigBuilder.setBaseDirectoryName("image_cache"); mainDiskCacheConfigBuilder.setBaseDirectoryPath(cacheDir); mainDiskCacheConfigBuilder.setMaxCacheSize(100 * 1024 * 1024); mainDiskCacheConfigBuilder.setVersion(1); configBuilder.setMainDiskCacheConfig(mainDiskCacheConfigBuilder.build()); final ImagePipelineConfig.Builder config = ImagePipelineConfig.newBuilder(this); if (BuildConfig.DEBUG) { final Set<RequestListener> requestListeners = new HashSet<>(); requestListeners.add(new RequestLoggingListener()); config.setRequestListeners(requestListeners); FLog.setMinimumLoggingLevel(FLog.VERBOSE); } configBuilder.setMemoryTrimmableRegistry(frescoMemoryTrimmableRegistry); Fresco.initialize(this, config.build()); }
private static void configureLoggingListeners(ImagePipelineConfig.Builder configBuilder) { Set<RequestListener> requestListeners = new HashSet<>(); requestListeners.add(new RequestLoggingListener()); configBuilder.setRequestListeners(requestListeners); }
@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()); }
private static void configureLoggingListeners(ImagePipelineConfig.Builder configBuilder) { Set<RequestListener> requestListeners = new HashSet<RequestListener>(); requestListeners.add(new RequestLoggingListener()); configBuilder.setRequestListeners(requestListeners); }