From a9b06a7fdec089028dbc2d4df627db8f7e375329 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Thu, 10 Jul 2014 21:34:19 -0400 Subject: [PATCH] One more static reference refactoring --- .../activity/downloader/DownloadActivityModules.java | 8 ++++++++ .../activity/downloader/manager/RefreshManager.java | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadActivityModules.java b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadActivityModules.java index 7e93390..39335b2 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadActivityModules.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadActivityModules.java @@ -8,8 +8,11 @@ import org.bspeice.minimalbible.activity.downloader.manager.RefreshManager; import org.crosswire.jsword.book.Book; import org.crosswire.jsword.book.BookCategory; import org.crosswire.jsword.book.Books; +import org.crosswire.jsword.book.install.InstallManager; +import org.crosswire.jsword.book.install.Installer; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import javax.inject.Named; @@ -82,4 +85,9 @@ public class DownloadActivityModules { List provideInstalledBooks(Books b) { return b.getBooks(); } + + @Provides @Singleton + Collection provideInstallers() { + return new InstallManager().getInstallers().values(); + } } diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.java b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.java index e0347df..3d47471 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.java @@ -10,6 +10,7 @@ import org.crosswire.jsword.book.install.InstallManager; import org.crosswire.jsword.book.install.Installer; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -39,6 +40,9 @@ public class RefreshManager { private Observable>> availableModules; private final AtomicBoolean refreshComplete = new AtomicBoolean(); + @Inject + Collection installers; + @Inject public RefreshManager(Injector injector) { injector.inject(this); @@ -52,7 +56,7 @@ public class RefreshManager { */ private Observable>> refreshModules() { if (availableModules == null) { - availableModules = Observable.from(new InstallManager().getInstallers().values()) + availableModules = Observable.from(installers) .map(new Func1>>() { @Override public Map> call(Installer installer) {