Merge branch 'master' into dependency-injection

This commit is contained in:
Paul Hawke 2017-11-24 22:12:43 -06:00
commit 02b5b9b680
148 changed files with 1169 additions and 364 deletions

View file

@ -7,6 +7,7 @@ import android.database.sqlite.SQLiteDatabase;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.stetho.Stetho;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
@ -60,17 +61,15 @@ public class CommonsApplication extends DaggerApplication {
public static final String FEEDBACK_EMAIL_SUBJECT = "Commons Android App (%s) Feedback";
private CommonsApplicationComponent component;
private RefWatcher refWatcher;
@Override
public void onCreate() {
super.onCreate();
if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
if (setupLeakCanary() == RefWatcher.DISABLED) {
return;
}
LeakCanary.install(this);
Timber.plant(new Timber.DebugTree());
@ -86,6 +85,18 @@ public class CommonsApplication extends DaggerApplication {
Fresco.initialize(this);
}
protected RefWatcher setupLeakCanary() {
if (LeakCanary.isInAnalyzerProcess(this)) {
return RefWatcher.DISABLED;
}
return LeakCanary.install(this);
}
public static RefWatcher getRefWatcher(Context context) {
CommonsApplication application = (CommonsApplication) context.getApplicationContext();
return application.refWatcher;
}
@Override
protected AndroidInjector<? extends DaggerApplication> applicationInjector() {
return injector();