浏览代码

Move dagger classes to injection directory

inorichi 9 年之前
父节点
当前提交
38c6fac385

+ 4 - 8
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<AppComponent> 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;

+ 1 - 1
app/src/main/java/eu/kanade/mangafeed/ComponentReflectionInjector.java → 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;

+ 3 - 2
app/src/main/java/eu/kanade/mangafeed/AppComponent.java → 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;

+ 1 - 1
app/src/main/java/eu/kanade/mangafeed/AppModule.java → 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;
 

+ 1 - 1
app/src/main/java/eu/kanade/mangafeed/data/DataModule.java → 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;
 

+ 1 - 1
app/src/main/java/eu/kanade/mangafeed/ui/activity/base/BaseRxActivity.java

@@ -59,7 +59,7 @@ public abstract class BaseRxActivity<P extends Presenter> extends BaseActivity i
         final PresenterFactory<P> superFactory = getPresenterFactory();
         setPresenterFactory(() -> {
             P presenter = superFactory.createPresenter();
-            App.getComponentReflection(getActivity()).inject(presenter);
+            ((App)getApplication()).getComponentReflection().inject(presenter);
             return presenter;
         });
 

+ 1 - 1
app/src/main/java/eu/kanade/mangafeed/ui/fragment/base/BaseRxFragment.java

@@ -56,7 +56,7 @@ public abstract class BaseRxFragment<P extends Presenter> extends BaseFragment i
         final PresenterFactory<P> superFactory = getPresenterFactory();
         setPresenterFactory(() -> {
             P presenter = superFactory.createPresenter();
-            App.getComponentReflection(getActivity()).inject(presenter);
+            ((App)getActivity().getApplication()).getComponentReflection().inject(presenter);
             return presenter;
         });