SEARCHING IS NOW WORKING

Needs some heavy work yet, but the core JSword functionality (the hardest part) is done.
This commit is contained in:
Bradlee Speice
2015-02-15 22:49:42 -05:00
parent 5197d4acfc
commit 52573534ef
5 changed files with 42 additions and 46 deletions

View File

@ -13,6 +13,7 @@ import rx.schedulers.Schedulers;
import rx.subjects.PublishSubject;
import org.crosswire.jsword.book.BookException
import org.crosswire.common.progress.Progress
import org.bspeice.minimalbible.activity.search.MBIndexManager
/**
* Single point of authority for what is being downloaded and its progress
@ -107,8 +108,8 @@ class BookManager(private val installedBooks: Books,
indexManager removeIndex realBook
return true
} catch (e: BookException) {
// Log.e("InstalledManager",
// "Unable to remove book (already uninstalled?): ${e.getDetailedMessage()}")
// Log.e("InstalledManager",
// "Unable to remove book (already uninstalled?): ${e.getDetailedMessage()}")
return false
}
}
@ -150,7 +151,7 @@ class BookManager(private val installedBooks: Books,
}
override fun workStateChanged(ev: WorkEvent) {
// Log.d("BookDownloadManager", ev.toString())
// Log.d("BookDownloadManager", ev.toString())
}
override fun bookAdded(booksEvent: BooksEvent) {

View File

@ -1,40 +1,32 @@
package org.bspeice.minimalbible.activity.downloader.manager
package org.bspeice.minimalbible.activity.search
import org.crosswire.jsword.index.IndexManager
import rx.subjects.PublishSubject
import org.crosswire.jsword.book.Book
import rx.Observable
import rx.schedulers.Schedulers
import android.util.Log
import rx.schedulers.Schedulers
import rx.Observable
/**
* There's already an IndexManager, that's why the funky name
*/
class MBIndexManager(val downloadEvents: PublishSubject<DLProgressEvent>,
val indexManager: IndexManager) {
val subscription = downloadEvents subscribe { handleDlEvent(it) }
fun handleDlEvent(event: DLProgressEvent): Unit =
if (event.progress == DLProgressEvent.PROGRESS_COMPLETE) {
subscription.unsubscribe()
buildIndex(event.b)
}
class MBIndexManager(val indexManager: IndexManager) {
fun buildIndex(b: Book) {
Observable.just(b)
.observeOn(Schedulers.computation())
.subscribe {
.subscribe({
try {
Log.d("MBIndexManager", "Beginning index status: ${b.getIndexStatus()}")
Log.e("MBIndexManager", "Beginning index status: ${b.getIndexStatus()}")
indexManager scheduleIndexCreation b
Log.d("MBIndexManager", "Ending index status: ${b.getIndexStatus()}")
Log.e("MBIndexManager", "Ending index status: ${b.getIndexStatus()}")
} catch (e: Exception) {
Log.e("MBIndexManager", "Exception building index: ${e}", e)
}
}
}, {
Log.e("MBIndexManager", "Exception building index: $it", it)
})
Log.d("MBIndexManager", "Building index for ${b.getInitials()}")
}
fun removeIndex(b: Book) = indexManager.deleteIndex(b)
}
}