From 38c6fac385fb423f1825f67a1f4df2df24efa3d1 Mon Sep 17 00:00:00 2001 From: inorichi Date: Wed, 21 Oct 2015 21:04:10 +0200 Subject: [PATCH] Move dagger classes to injection directory --- app/src/main/java/eu/kanade/mangafeed/App.java | 12 ++++-------- .../{ => injection}/ComponentReflectionInjector.java | 2 +- .../{ => injection/component}/AppComponent.java | 5 +++-- .../mangafeed/{ => injection/module}/AppModule.java | 2 +- .../{data => injection/module}/DataModule.java | 2 +- .../mangafeed/ui/activity/base/BaseRxActivity.java | 2 +- .../mangafeed/ui/fragment/base/BaseRxFragment.java | 2 +- 7 files changed, 12 insertions(+), 15 deletions(-) rename app/src/main/java/eu/kanade/mangafeed/{ => injection}/ComponentReflectionInjector.java (98%) rename app/src/main/java/eu/kanade/mangafeed/{ => injection/component}/AppComponent.java (86%) rename app/src/main/java/eu/kanade/mangafeed/{ => injection/module}/AppModule.java (91%) rename app/src/main/java/eu/kanade/mangafeed/{data => injection/module}/DataModule.java (96%) diff --git a/app/src/main/java/eu/kanade/mangafeed/App.java b/app/src/main/java/eu/kanade/mangafeed/App.java index 4d3ee28769..ceb02d8ed9 100644 --- a/app/src/main/java/eu/kanade/mangafeed/App.java +++ b/app/src/main/java/eu/kanade/mangafeed/App.java @@ -5,6 +5,10 @@ import android.content.Context; import org.acra.annotation.ReportsCrashes; +import eu.kanade.mangafeed.injection.component.AppComponent; +import eu.kanade.mangafeed.injection.module.AppModule; +import eu.kanade.mangafeed.injection.ComponentReflectionInjector; +import eu.kanade.mangafeed.injection.component.DaggerAppComponent; import timber.log.Timber; @ReportsCrashes( @@ -46,14 +50,6 @@ public class App extends Application { return mComponentInjector; } - public static ComponentReflectionInjector getComponentReflection(Context context) { - return get(context).getComponentReflection(); - } - - public static AppComponent getComponent(Context context) { - return get(context).getComponent(); - } - // Needed to replace the component with a test specific one public void setComponent(AppComponent applicationComponent) { mApplicationComponent = applicationComponent; diff --git a/app/src/main/java/eu/kanade/mangafeed/ComponentReflectionInjector.java b/app/src/main/java/eu/kanade/mangafeed/injection/ComponentReflectionInjector.java similarity index 98% rename from app/src/main/java/eu/kanade/mangafeed/ComponentReflectionInjector.java rename to app/src/main/java/eu/kanade/mangafeed/injection/ComponentReflectionInjector.java index 99c97a46c3..0cb4bd87cf 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ComponentReflectionInjector.java +++ b/app/src/main/java/eu/kanade/mangafeed/injection/ComponentReflectionInjector.java @@ -1,4 +1,4 @@ -package eu.kanade.mangafeed; +package eu.kanade.mangafeed.injection; import java.lang.reflect.Method; import java.util.HashMap; diff --git a/app/src/main/java/eu/kanade/mangafeed/AppComponent.java b/app/src/main/java/eu/kanade/mangafeed/injection/component/AppComponent.java similarity index 86% rename from app/src/main/java/eu/kanade/mangafeed/AppComponent.java rename to app/src/main/java/eu/kanade/mangafeed/injection/component/AppComponent.java index f058920ae4..52dd081980 100644 --- a/app/src/main/java/eu/kanade/mangafeed/AppComponent.java +++ b/app/src/main/java/eu/kanade/mangafeed/injection/component/AppComponent.java @@ -1,11 +1,12 @@ -package eu.kanade.mangafeed; +package eu.kanade.mangafeed.injection.component; import android.app.Application; import javax.inject.Singleton; import dagger.Component; -import eu.kanade.mangafeed.data.DataModule; +import eu.kanade.mangafeed.injection.module.AppModule; +import eu.kanade.mangafeed.injection.module.DataModule; import eu.kanade.mangafeed.presenter.CataloguePresenter; import eu.kanade.mangafeed.presenter.LibraryPresenter; import eu.kanade.mangafeed.presenter.MangaChaptersPresenter; diff --git a/app/src/main/java/eu/kanade/mangafeed/AppModule.java b/app/src/main/java/eu/kanade/mangafeed/injection/module/AppModule.java similarity index 91% rename from app/src/main/java/eu/kanade/mangafeed/AppModule.java rename to app/src/main/java/eu/kanade/mangafeed/injection/module/AppModule.java index a9b8c37848..e512d06cd9 100644 --- a/app/src/main/java/eu/kanade/mangafeed/AppModule.java +++ b/app/src/main/java/eu/kanade/mangafeed/injection/module/AppModule.java @@ -1,4 +1,4 @@ -package eu.kanade.mangafeed; +package eu.kanade.mangafeed.injection.module; import android.app.Application; diff --git a/app/src/main/java/eu/kanade/mangafeed/data/DataModule.java b/app/src/main/java/eu/kanade/mangafeed/injection/module/DataModule.java similarity index 96% rename from app/src/main/java/eu/kanade/mangafeed/data/DataModule.java rename to app/src/main/java/eu/kanade/mangafeed/injection/module/DataModule.java index b18a3dc933..0c5cd3fa36 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/DataModule.java +++ b/app/src/main/java/eu/kanade/mangafeed/injection/module/DataModule.java @@ -1,4 +1,4 @@ -package eu.kanade.mangafeed.data; +package eu.kanade.mangafeed.injection.module; import android.app.Application; diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/activity/base/BaseRxActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/activity/base/BaseRxActivity.java index e8ef7bc577..d47e8b218b 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/activity/base/BaseRxActivity.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/activity/base/BaseRxActivity.java @@ -59,7 +59,7 @@ public abstract class BaseRxActivity

extends BaseActivity i final PresenterFactory

superFactory = getPresenterFactory(); setPresenterFactory(() -> { P presenter = superFactory.createPresenter(); - App.getComponentReflection(getActivity()).inject(presenter); + ((App)getApplication()).getComponentReflection().inject(presenter); return presenter; }); diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/fragment/base/BaseRxFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/fragment/base/BaseRxFragment.java index 6308fcd752..93174e6054 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/fragment/base/BaseRxFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/fragment/base/BaseRxFragment.java @@ -56,7 +56,7 @@ public abstract class BaseRxFragment

extends BaseFragment i final PresenterFactory

superFactory = getPresenterFactory(); setPresenterFactory(() -> { P presenter = superFactory.createPresenter(); - App.getComponentReflection(getActivity()).inject(presenter); + ((App)getActivity().getApplication()).getComponentReflection().inject(presenter); return presenter; });