diff --git a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/EventBookList.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/EventBookList.java deleted file mode 100644 index 353788f..0000000 --- a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/EventBookList.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.bspeice.minimalbible.activities.downloader.manager; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.crosswire.jsword.book.Book; -import org.crosswire.jsword.book.install.Installer; - -/** - * POJO class for {@link de.greenrobot.event.EventBus} to broadcast whenever - * we've finished updating the book list. - */ -public class EventBookList { - - private Map> bookMapping; - - public EventBookList(Map> bookList) { - this.bookMapping = bookList; - } - - public Map> getInstallerMapping() { - return bookMapping; - } - - public List getBookList() { - List bookList = new ArrayList(); - for (Installer i: bookMapping.keySet()) { - bookList.addAll(bookMapping.get(i)); - } - return bookList; - } -} diff --git a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/RefreshManager.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/RefreshManager.java index ab3e1dc..4e036b9 100644 --- a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/RefreshManager.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/RefreshManager.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; import javax.inject.Inject; import javax.inject.Singleton; @@ -29,7 +30,7 @@ public class RefreshManager { * Cached copy of modules that are available so we don't refresh for everyone who requests it. */ private Observable>> availableModules; - private boolean refreshComplete; + private final AtomicBoolean refreshComplete = new AtomicBoolean(); public RefreshManager() { MinimalBible.getApplication().inject(this); @@ -53,7 +54,7 @@ public class RefreshManager { // Set refresh complete when it is. availableModules.subscribeOn(AndroidSchedulers.handlerThread(backgroundHandler)) - .subscribe(null, null, () -> refreshComplete = true); + .subscribe(null, null, () -> refreshComplete.set(true)); } } @@ -89,4 +90,8 @@ public class RefreshManager { .take(1) .map(element -> element.entrySet().iterator().next().getKey()); } + + public boolean isRefreshComplete() { + return refreshComplete.get(); + } }