One more static reference refactoring

This commit is contained in:
Bradlee Speice 2014-07-10 21:34:19 -04:00
parent 80e38dacb4
commit a9b06a7fde
2 changed files with 13 additions and 1 deletions

View File

@ -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<Book> provideInstalledBooks(Books b) {
return b.getBooks();
}
@Provides @Singleton
Collection<Installer> provideInstallers() {
return new InstallManager().getInstallers().values();
}
}

View File

@ -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<Map<Installer, List<Book>>> availableModules;
private final AtomicBoolean refreshComplete = new AtomicBoolean();
@Inject
Collection<Installer> installers;
@Inject
public RefreshManager(Injector injector) {
injector.inject(this);
@ -52,7 +56,7 @@ public class RefreshManager {
*/
private Observable<Map<Installer, List<Book>>> refreshModules() {
if (availableModules == null) {
availableModules = Observable.from(new InstallManager().getInstallers().values())
availableModules = Observable.from(installers)
.map(new Func1<Installer, Map<Installer, List<Book>>>() {
@Override
public Map<Installer, List<Book>> call(Installer installer) {