From 899b054c8b2a1baf00a8ac7fbfbcac247dec7754 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Tue, 10 Jun 2014 22:37:53 -0400 Subject: [PATCH] [broken] Slight semantic change to RefreshManager --- .../downloader/manager/EventBookList.java | 33 ------------------- .../downloader/manager/RefreshManager.java | 9 +++-- 2 files changed, 7 insertions(+), 35 deletions(-) delete mode 100644 MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/EventBookList.java 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(); + } }