DataModule.java 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package eu.kanade.mangafeed.injection.module;
  2. import android.app.Application;
  3. import javax.inject.Singleton;
  4. import dagger.Module;
  5. import dagger.Provides;
  6. import eu.kanade.mangafeed.data.cache.CacheManager;
  7. import eu.kanade.mangafeed.data.database.DatabaseHelper;
  8. import eu.kanade.mangafeed.data.download.DownloadManager;
  9. import eu.kanade.mangafeed.data.network.NetworkHelper;
  10. import eu.kanade.mangafeed.data.preference.PreferencesHelper;
  11. import eu.kanade.mangafeed.data.source.SourceManager;
  12. /**
  13. * Provide dependencies to the DataManager, mainly Helper classes and Retrofit services.
  14. */
  15. @Module
  16. public class DataModule {
  17. @Provides
  18. @Singleton
  19. PreferencesHelper providePreferencesHelper(Application app) {
  20. return new PreferencesHelper(app);
  21. }
  22. @Provides
  23. @Singleton
  24. DatabaseHelper provideDatabaseHelper(Application app) {
  25. return new DatabaseHelper(app);
  26. }
  27. @Provides
  28. @Singleton
  29. CacheManager provideCacheManager(Application app) {
  30. return new CacheManager(app);
  31. }
  32. @Provides
  33. @Singleton
  34. NetworkHelper provideNetworkHelper() {
  35. return new NetworkHelper();
  36. }
  37. @Provides
  38. @Singleton
  39. SourceManager provideSourceManager(Application app) {
  40. return new SourceManager(app);
  41. }
  42. @Provides
  43. @Singleton
  44. DownloadManager provideDownloadManager(
  45. Application app, SourceManager sourceManager, PreferencesHelper preferences) {
  46. return new DownloadManager(app, sourceManager, preferences);
  47. }
  48. }