package de.philipphager.disclosure;

import android.app.Application;
import com.facebook.stetho.Stetho;
import com.jakewharton.threetenabp.AndroidThreeTen;
import com.squareup.leakcanary.LeakCanary;
import timber.log.Timber;

import static de.philipphager.disclosure.util.assertion.Assertions.ensureNotNull;

public class DisclosureApp extends Application {
  private ApplicationComponent applicationComponent;

  @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.
      return;
    }
    LeakCanary.install(this);

    /**
     * TODO: Remove on update!
     * Avoiding a memory leak of Android's UserManager.
     * It is caching a static instance and leaks,
     * on Activity recreation, unless UserManager.get()
     * is called before.
     * This is a temporary prevention of memory leaks
     * and should be removed instantly after upgrading Android.
     */
    getPackageManager().getUserBadgedLabel("", android.os.Process.myUserHandle());

    buildObjectGraphAndInject();
  }

  private void buildObjectGraphAndInject() {
    applicationComponent = DaggerApplicationComponent.builder()
        .applicationModule(new ApplicationModule(this))
        .build();

    AndroidThreeTen.init(this);

    if (BuildConfig.DEBUG) {
      Stetho.initializeWithDefaults(this);
      Timber.plant(new Timber.DebugTree());
    }
  }

  public ApplicationComponent getApplicationComponent() {
    return ensureNotNull(applicationComponent, "object graph not build");
  }
}

@@ -695,436 +695,33 @@
     
-/**%0A     * TODO: Remove on update!%0A     * Avoiding a memory leak of Android's UserManager.%0A     * It is caching a static instance and leaks,%0A     * on Activity recreation, unless UserManager.get()%0A     * is called before.%0A     * This is a temporary prevention of memory leaks%0A     * and should be removed instantly after upgrading Android.%0A     */%0A    getPackageManager().getUserBadgedLabel(%22%22, android.os.Process.myUserHandle()
+fixUserManagerMemoryLeak(
 );%0A%0A
@@ -1238,10 +1238,474 @@
 %22);%0A  %7D%0A
+%0A%0A  /**%0A   * TODO: Remove on update!%0A   * Avoiding a memory leak of Android's UserManager. It is caching a static%0A   * instance and leaks, on Activity recreation, unless UserManager.get()%0A   * is called before. This is a temporary prevention a specific memory%0A   * leak and should be removed instantly after upgrading Android.%0A   */%0A  private void fixUserManagerMemoryLeak() %7B%0A    getPackageManager().getUserBadgedLabel(%22%22, android.os.Process.myUserHandle());%0A  %7D%0A
 %7D%0A

Move memory leak fix into method