/*
 * MIT License
 *
 * Copyright (c) 2017 zhangls2014
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * 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 THE
 * AUTHORS OR COPYRIGHT HOLDERS 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 cn.zhangls.android.weibo.common;

import android.app.Application;

import com.squareup.leakcanary.LeakCanary;

/**
 * Created by zhangls{github.com/zhangls2014} on 2017/1/16.
 * <p>
 * 自定义 Application 子类
 */

public class App extends Application {
    /**
     * Called when the application is starting, before any activity, service,
     * or receiver objects (excluding content providers) have been created.
     * Implementations should be as quick as possible (for example using
     * lazy initialization of state) since the time spent in this function
     * directly impacts the performance of starting the first activity,
     * service, or receiver in a process.
     * If you override this method, be sure to call super.onCreate().
     */
    @Override
    public void onCreate() {
        super.onCreate();
        LeakCanary.install(this);
    }
}

@@ -1201,16 +1201,46 @@
 ication;
+%0Aimport android.os.StrictMode;
 %0A%0Aimport
@@ -1277,16 +1277,123 @@
 anary;%0A%0A
+import static android.os.Build.VERSION.SDK_INT;%0Aimport static android.os.Build.VERSION_CODES.GINGERBREAD;%0A%0A
 /**%0A * C
@@ -1521,16 +1521,17 @@
 ation %7B%0A
+%0A
     /**%0A
@@ -2105,33 +2105,596 @@
     
-LeakCanary.install(this);
+if (LeakCanary.isInAnalyzerProcess(this)) %7B%0A            // This process is dedicated to LeakCanary for heap analysis.%0A            // You should not init your app in this process.%0A            return;%0A        %7D%0A        enabledStrictMode();%0A        LeakCanary.install(this);%0A    %7D%0A%0A    private void enabledStrictMode() %7B%0A        if (SDK_INT %3E= GINGERBREAD) %7B%0A            StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() //%0A                    .detectAll() //%0A                    .penaltyLog() //%0A                    .penaltyDeath() //%0A                    .build());%0A        %7D
 %0A   

add library: LeakCanary