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

69 lines
2 KiB
Java
Raw Normal View History

2016-01-15 09:18:19 -05:00
package eu.kanade.tachiyomi;
2015-09-24 11:27:43 -04:00
import android.app.Application;
import android.content.Context;
import org.acra.ACRA;
2015-10-05 06:47:10 -04:00
import org.acra.annotation.ReportsCrashes;
2016-02-09 15:19:11 -05:00
import org.greenrobot.eventbus.EventBus;
2015-10-05 06:47:10 -04:00
2016-01-15 09:18:19 -05: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 11:27:43 -04:00
import timber.log.Timber;
2015-10-05 06:47:10 -04:00
@ReportsCrashes(
2016-01-17 09:03:04 -05:00
formUri = "http://tachiyomi.kanade.eu/crash_report",
2015-10-05 06:47:10 -04:00
reportType = org.acra.sender.HttpSender.Type.JSON,
httpMethod = org.acra.sender.HttpSender.Method.PUT,
excludeMatchingSharedPreferencesKeys={".*username.*",".*password.*"}
2015-10-05 06:47:10 -04:00
)
2015-09-24 11:27:43 -04:00
public class App extends Application {
AppComponent applicationComponent;
ComponentReflectionInjector<AppComponent> componentInjector;
2015-09-24 11:27:43 -04:00
public static App get(Context context) {
return (App) context.getApplicationContext();
}
2015-09-24 11:27:43 -04:00
@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree());
applicationComponent = prepareAppComponent().build();
2015-10-05 06:47:10 -04:00
componentInjector =
new ComponentReflectionInjector<>(AppComponent.class, applicationComponent);
2015-10-16 13:31:18 -04:00
setupEventBus();
setupAcra();
}
protected DaggerAppComponent.Builder prepareAppComponent() {
return DaggerAppComponent.builder()
.appModule(new AppModule(this));
}
protected void setupEventBus() {
2016-02-09 15:19:11 -05:00
EventBus.builder()
.addIndex(new EventBusIndex())
.logNoSubscriberMessages(false)
.installDefaultEventBus();
2015-09-24 11:27:43 -04:00
}
protected void setupAcra() {
ACRA.init(this);
2015-09-24 11:27:43 -04:00
}
public AppComponent getComponent() {
return applicationComponent;
2015-09-24 11:27:43 -04:00
}
public ComponentReflectionInjector<AppComponent> getComponentReflection() {
return componentInjector;
}
2015-09-24 11:27:43 -04:00
}