/*
 * This file provided by Facebook is for non-commercial testing and evaluation
 * purposes only.  Facebook reserves all rights not expressly granted.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package com.facebook.fresco.samples.showcase;

import android.app.Application;
import android.content.Context;
import com.facebook.common.internal.Supplier;
import com.facebook.common.logging.FLog;
import com.facebook.drawee.backends.pipeline.DraweeConfig;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.fresco.samples.showcase.misc.DebugOverlaySupplierSingleton;
import com.facebook.imagepipeline.backends.okhttp3.OkHttpImagePipelineConfigFactory;
import com.facebook.imagepipeline.core.ImagePipelineConfig;
import com.facebook.imagepipeline.decoder.SimpleProgressiveJpegConfig;
import com.facebook.imagepipeline.listener.RequestListener;
import com.facebook.imagepipeline.listener.RequestLoggingListener;
import com.facebook.imagepipeline.stetho.FrescoStethoPlugin;
import com.facebook.stetho.DumperPluginsProvider;
import com.facebook.stetho.Stetho;
import com.facebook.stetho.dumpapp.DumperPlugin;
import com.facebook.stetho.okhttp3.StethoInterceptor;
import java.util.HashSet;
import java.util.Set;
import okhttp3.OkHttpClient;

/**
 * Showcase Application implementation where we set up Fresco
 */
public class ShowcaseApplication extends Application {

  @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)
        .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();
          }
        })
        .build());
  }
}

@@ -2185,16 +2185,24 @@
 Config =
+%0A       
  OkHttpI
@@ -2226,25 +2226,16 @@
 gFactory
-%0A        
 .newBuil
@@ -2258,16 +2258,20 @@
 Client)%0A
+    
         
@@ -2302,16 +2302,20 @@
 teners)%0A
+    
         
@@ -2379,24 +2379,28 @@
 ())%0A        
+    
 .setImageDec
@@ -2472,32 +2472,36 @@
 (this))%0A        
+    
 .experiment().se
@@ -2493,24 +2493,37 @@
 experiment()
+%0A            
 .setMediaVar
@@ -2542,16 +2542,33 @@
 Enabled(
+%0A                
 new Supp
@@ -2587,32 +2587,40 @@
 %3E() %7B%0A          
+        
 @Override%0A      
@@ -2619,24 +2619,32 @@
 e%0A          
+  
+      
 public Boole
@@ -2662,24 +2662,32 @@
             
+      
+  
 return true;
@@ -2693,37 +2693,57 @@
 ;%0A          
-%7D%0A        %7D)%0A
+        %7D%0A                %7D)%0A    
         .exp
@@ -2751,16 +2751,29 @@
 riment()
+%0A            
 .setBitm
@@ -2816,16 +2816,89 @@
 _VALUE)%0A
+            .experiment()%0A            .setSmartResizingEnabled(true)%0A    
         

Enable smart resizing experiment for Showcase app