Get the unit tests passing again

Note: I need to write more. Lots more.
This commit is contained in:
Bradlee Speice
2014-06-14 16:25:13 -04:00
parent 04fe4d13b4
commit e945ef51a7
5 changed files with 32 additions and 44 deletions

View File

@ -118,11 +118,7 @@ public class BookListFragment extends BaseFragment {
}
// Listen for the books!
refreshManager.getAvailableModules()
// First flatten the Map to its lists
.flatMap((books) -> Observable.from(books.values()))
// Then flatten the lists
.flatMap(Observable::from)
refreshManager.getAvailableModulesFlattened()
.filter((book) -> book.getBookCategory() ==
BookCategory.fromString(getArguments().getString(ARG_BOOK_CATEGORY)))
// Repack all the books

View File

@ -56,6 +56,7 @@ public class BookDownloadManager implements WorkListener, BooksListener {
BookDownloadThread dlThread = dlThreadProvider.get();
dlThread.downloadBook(b);
addJob(BookDownloadThread.getJobId(b), b);
downloadEvents.onNext(new DLProgressEvent(DLProgressEvent.PROGRESS_BEGINNING, b));
}
public void addJob(String jobId, Book b) {

View File

@ -63,6 +63,9 @@ public class InstalledManager implements BooksListener {
}
public void removeBook(Book b) {
if (installedBooks == null) {
initialize();
}
try {
// This worked in the past, but isn't now...
// installedBooks.remove(b);

View File

@ -61,6 +61,14 @@ public class RefreshManager {
return availableModules;
}
public Observable<Book> getAvailableModulesFlattened() {
return availableModules
// First flatten the Map to its lists
.flatMap((books) -> Observable.from(books.values()))
// Then flatten the lists
.flatMap(Observable::from);
}
/**
* Get the cached book list
* @return The cached book list, or null
@ -90,7 +98,7 @@ public class RefreshManager {
}
return false;
})
.take(1)
.first()
.map(element -> element.entrySet().iterator().next().getKey());
}