DataModule.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.cache.CoverCache;
  8. import eu.kanade.mangafeed.data.mangasync.MangaSyncManager;
  9. import eu.kanade.mangafeed.data.database.DatabaseHelper;
  10. import eu.kanade.mangafeed.data.download.DownloadManager;
  11. import eu.kanade.mangafeed.data.network.NetworkHelper;
  12. import eu.kanade.mangafeed.data.preference.PreferencesHelper;
  13. import eu.kanade.mangafeed.data.source.SourceManager;
  14. /**
  15. * Provide dependencies to the DataManager, mainly Helper classes and Retrofit services.
  16. */
  17. @Module
  18. public class DataModule {
  19. @Provides
  20. @Singleton
  21. PreferencesHelper providePreferencesHelper(Application app) {
  22. return new PreferencesHelper(app);
  23. }
  24. @Provides
  25. @Singleton
  26. DatabaseHelper provideDatabaseHelper(Application app) {
  27. return new DatabaseHelper(app);
  28. }
  29. @Provides
  30. @Singleton
  31. CacheManager provideCacheManager(Application app, PreferencesHelper preferences) {
  32. return new CacheManager(app, preferences);
  33. }
  34. @Provides
  35. @Singleton
  36. CoverCache provideCoverCache(Application app) {
  37. return new CoverCache(app);
  38. }
  39. @Provides
  40. @Singleton
  41. NetworkHelper provideNetworkHelper() {
  42. return new NetworkHelper();
  43. }
  44. @Provides
  45. @Singleton
  46. SourceManager provideSourceManager(Application app) {
  47. return new SourceManager(app);
  48. }
  49. @Provides
  50. @Singleton
  51. DownloadManager provideDownloadManager(
  52. Application app, SourceManager sourceManager, PreferencesHelper preferences) {
  53. return new DownloadManager(app, sourceManager, preferences);
  54. }
  55. @Provides
  56. @Singleton
  57. MangaSyncManager provideMangaSyncManager(Application app) {
  58. return new MangaSyncManager(app);
  59. }
  60. }