[broken] Slight semantic change to RefreshManager

This commit is contained in:
Bradlee Speice 2014-06-10 22:37:53 -04:00
parent 8f346f17e4
commit 899b054c8b
2 changed files with 7 additions and 35 deletions

View File

@ -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<Installer, List<Book>> bookMapping;
public EventBookList(Map<Installer, List<Book>> bookList) {
this.bookMapping = bookList;
}
public Map<Installer, List<Book>> getInstallerMapping() {
return bookMapping;
}
public List<Book> getBookList() {
List<Book> bookList = new ArrayList<Book>();
for (Installer i: bookMapping.keySet()) {
bookList.addAll(bookMapping.get(i));
}
return bookList;
}
}

View File

@ -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<Map<Installer, List<Book>>> 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();
}
}