// Path: app/src/main/java/com/yunq/gankio/GankApp.java
// public class GankApp extends Application {
// 
//     private RefWatcher refWatcher;
// 
//     ApplicationComponent mApplicationComponent;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         refWatcher = LeakCanary.install(this);
// 
//         if (BuildConfig.DEBUG) {
//             //警告在主线程中执行耗时操作
//             StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
//             StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
// 
//             Timber.plant(new Timber.DebugTree());
//         }
// 
//     }
// 
//     public static GankApp get(Context context) {
//         return (GankApp) context.getApplicationContext();
//     }
// 
//     public static RefWatcher getRefWatcher(Context context) {
//         return ((GankApp) context.getApplicationContext()).refWatcher;
//     }
// 
//     public ApplicationComponent getComponent() {
//         if (mApplicationComponent == null) {
//             mApplicationComponent = DaggerApplicationComponent.builder()
//                     .applicationModule(new ApplicationModule(this))
//                     .build();
//         }
//         return mApplicationComponent;
//     }
// 
// 
// }


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import com.yunq.gankio.GankApp;
import com.yunq.gankio.R;
import butterknife.Bind;
import butterknife.ButterKnife;
        initInjection();
        initToolBar();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(getMenuRes(), menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                break;
        }
        return super.onOptionsItemSelected(item);
    }

    public void setTitle(String tilte, boolean showHome) {
        setTitle(tilte);
        getSupportActionBar().setDisplayHomeAsUpEnabled(showHome);
        getSupportActionBar().setDisplayShowHomeEnabled(showHome);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
// Path: app/src/main/java/com/yunq/gankio/GankApp.java
// public class GankApp extends Application {
// 
//     private RefWatcher refWatcher;
// 
//     ApplicationComponent mApplicationComponent;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         refWatcher = LeakCanary.install(this);
// 
//         if (BuildConfig.DEBUG) {
//             //警告在主线程中执行耗时操作
//             StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
//             StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
// 
//             Timber.plant(new Timber.DebugTree());
//         }
// 
//     }
// 
//     public static GankApp get(Context context) {
//         return (GankApp) context.getApplicationContext();
//     }
// 
//     public static RefWatcher getRefWatcher(Context context) {
//         return ((GankApp) context.getApplicationContext()).refWatcher;
//     }
// 
//     public ApplicationComponent getComponent() {
//         if (mApplicationComponent == null) {
//             mApplicationComponent = DaggerApplicationComponent.builder()
//                     .applicationModule(new ApplicationModule(this))
//                     .build();
//         }
//         return mApplicationComponent;
//     }
// 
// 
// }


// Path: app/src/main/java/com/yunq/gankio/ui/BaseActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import com.yunq.gankio.GankApp;
import com.yunq.gankio.R;
import butterknife.Bind;
import butterknife.ButterKnife;

        initInjection();
        initToolBar();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(getMenuRes(), menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                break;
        }
        return super.onOptionsItemSelected(item);
    }

    public void setTitle(String tilte, boolean showHome) {
        setTitle(tilte);
        getSupportActionBar().setDisplayHomeAsUpEnabled(showHome);
        getSupportActionBar().setDisplayShowHomeEnabled(showHome);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
        GankApp.getRefWatcher(this).watch(this);