package com.nutrition.express.application;

import android.app.Application;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.nutrition.express.model.rest.RestClient;

/**
 * Created by huang on 4/25/16.
 */
public class ExpressApplication extends Application {
    public static int width;
    public static int height;
    private static ExpressApplication application;

    @Override
    public void onCreate() {
        super.onCreate();
        application = this;
        Fresco.initialize(this);

        //init width and height
        DisplayMetrics dm = new DisplayMetrics();
        WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        wm.getDefaultDisplay().getMetrics(dm);
        width = dm.widthPixels;
        height = dm.heightPixels;

        //init retrofit
        RestClient.getInstance().init(this);
    }

    public static ExpressApplication getApplication() {
        return application;
    }
}

@@ -197,39 +197,147 @@
 ook.
-drawee.backends.pipeline.Fresco
+cache.disk.DiskCacheConfig;%0Aimport com.facebook.drawee.backends.pipeline.Fresco;%0Aimport com.facebook.imagepipeline.core.ImagePipelineConfig
 ;%0Aim
@@ -590,16 +590,69 @@
 ication;
+%0A    private ImagePipelineConfig imagePipelineConfig;
 %0A%0A    @O
@@ -742,16 +742,355 @@
 = this;%0A
+        DiskCacheConfig cacheConfig = DiskCacheConfig.newBuilder(this)%0A                .setMaxCacheSize(300 * 1024 * 1024)%0A                .build();%0A        imagePipelineConfig = ImagePipelineConfig.newBuilder(this)%0A                .setMainDiskCacheConfig(cacheConfig)%0A                .setDownsampleEnabled(true)%0A                .build();%0A
         
@@ -1111,16 +1111,37 @@
 ize(this
+, imagePipelineConfig
 );%0A%0A    
@@ -1545,24 +1545,24 @@
 ication() %7B%0A
-
         retu
@@ -1582,11 +1582,112 @@
 n;%0A    %7D
+%0A%0A    public ImagePipelineConfig getImagePipelineConfig() %7B%0A        return imagePipelineConfig;%0A    %7D
 %0A%7D%0A

set fresco cache size