mihon/app/src/main/java/eu/kanade/tachiyomi/App.java

58 lines
1.8 KiB
Java
Raw Normal View History

2016-01-15 15:18:19 +01:00
package eu.kanade.tachiyomi;
2015-09-24 17:27:43 +02:00
import android.app.Application;
import android.content.Context;
import org.acra.ACRA;
2015-10-05 12:47:10 +02:00
import org.acra.annotation.ReportsCrashes;
2016-01-15 15:18:19 +01:00
import eu.kanade.tachiyomi.injection.ComponentReflectionInjector;
import eu.kanade.tachiyomi.injection.component.AppComponent;
import eu.kanade.tachiyomi.injection.component.DaggerAppComponent;
import eu.kanade.tachiyomi.injection.module.AppModule;
2015-09-24 17:27:43 +02:00
import timber.log.Timber;
2015-10-05 12:47:10 +02:00
@ReportsCrashes(
formUri = "http://mangafeed.kanade.eu/crash_report",
2015-10-05 12:47:10 +02:00
reportType = org.acra.sender.HttpSender.Type.JSON,
httpMethod = org.acra.sender.HttpSender.Method.PUT,
excludeMatchingSharedPreferencesKeys={".*username.*",".*password.*"}
2015-10-05 12:47:10 +02:00
)
2015-09-24 17:27:43 +02:00
public class App extends Application {
AppComponent applicationComponent;
ComponentReflectionInjector<AppComponent> componentInjector;
2015-09-24 17:27:43 +02:00
@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree());
applicationComponent = DaggerAppComponent.builder()
2015-09-24 17:27:43 +02:00
.appModule(new AppModule(this))
.build();
2015-10-05 12:47:10 +02:00
componentInjector =
new ComponentReflectionInjector<>(AppComponent.class, applicationComponent);
2015-10-16 19:31:18 +02:00
ACRA.init(this);
2015-09-24 17:27:43 +02:00
}
public static App get(Context context) {
return (App) context.getApplicationContext();
}
public AppComponent getComponent() {
return applicationComponent;
2015-09-24 17:27:43 +02:00
}
2015-10-16 19:31:18 +02:00
public ComponentReflectionInjector<AppComponent> getComponentReflection() {
return componentInjector;
2015-10-16 19:31:18 +02:00
}
2015-09-24 17:27:43 +02:00
// Needed to replace the component with a test specific one
public void setComponent(AppComponent applicationComponent) {
this.applicationComponent = applicationComponent;
2015-09-24 17:27:43 +02:00
}
}