Properly remove a book

Not sure why it needs to be implemented this way...
This commit is contained in:
Bradlee Speice 2014-11-12 00:09:24 -05:00
parent b65b5680f9
commit cce463cde9

View File

@ -14,7 +14,6 @@ import rx.Observable;
import rx.schedulers.Schedulers; import rx.schedulers.Schedulers;
import rx.subjects.PublishSubject; import rx.subjects.PublishSubject;
import org.crosswire.jsword.book.BookException import org.crosswire.jsword.book.BookException
import org.crosswire.jsword.book.remove
/** /**
* Single point of authority for what is being downloaded and its progress * Single point of authority for what is being downloaded and its progress
@ -75,12 +74,15 @@ class BookManager(private val installedBooks: Books, val rM: RefreshManager) :
* Remove a book from being installed. * Remove a book from being installed.
* Currently only supports books that have been installed outside the current application run. * Currently only supports books that have been installed outside the current application run.
* Not quite sure why this is, but And-Bible exhibits the same behavior. * Not quite sure why this is, but And-Bible exhibits the same behavior.
* Also, make sure to manually test if you change this implementation. The `drivers` are
* a bit persnickety.
* @param b The book to remove * @param b The book to remove
* @return Whether the book was removed. * @return Whether the book was removed.
*/ */
fun removeBook(b: Book): Boolean { fun removeBook(b: Book): Boolean {
try { try {
b.remove() val realBook = installedBooks getBook b.getInitials()
realBook.getDriver().delete(b)
return installedBooksList remove b return installedBooksList remove b
} catch (e: BookException) { } catch (e: BookException) {
Log.e("InstalledManager", Log.e("InstalledManager",