mirror of
https://github.com/MinimalBible/MinimalBible
synced 2025-07-01 05:45:58 -04:00
Kotlin migration is done!
There will of course be refactoring and whatnot, but I consider this an accomplishment.
This commit is contained in:
@ -1,35 +1,34 @@
|
||||
package org.bspeice.minimalbible.activity.viewer
|
||||
|
||||
import org.crosswire.jsword.passage.Verse
|
||||
import org.bspeice.minimalbible.service.book.VerseLookupService
|
||||
import android.webkit.WebViewClient
|
||||
import android.webkit.JavascriptInterface
|
||||
import org.crosswire.jsword.book.Book
|
||||
import java.util.ArrayList
|
||||
import android.util.Log
|
||||
import rx.subjects.PublishSubject
|
||||
import org.crosswire.jsword.book.getVersification
|
||||
import org.bspeice.minimalbible.service.lookup.VerseLookup
|
||||
|
||||
/**
|
||||
* Created by bspeice on 9/14/14.
|
||||
*/
|
||||
|
||||
class BibleViewClient(val b: Book, val lookup: VerseLookupService,
|
||||
class BibleViewClient(val b: Book, val lookup: VerseLookup,
|
||||
val subject: PublishSubject<String>?) : WebViewClient() {
|
||||
|
||||
// We can receive and return only primitives and Strings. Still means we can use JSON :)
|
||||
JavascriptInterface fun getVerse(ordinal: Int): String {
|
||||
val v = Verse(b.getVersification(), ordinal)
|
||||
// TODO: WebView should notify us what verse it's on
|
||||
subject?.onNext(v.getBook().toString() + " " + v.getChapter() + ":" + v.getVerse())
|
||||
return lookup.getJsonVerse(v)
|
||||
subject?.onNext("${v.getBook()} ${v.getChapter()}:${v.getVerse()}")
|
||||
return lookup getJson v
|
||||
}
|
||||
|
||||
JavascriptInterface fun getVerses(first: Int, count: Int): String {
|
||||
Log.e("getVerses", "First: " + first + " count: " + count)
|
||||
val verses: MutableList<String> = ArrayList<String>()
|
||||
var trueCount: Int
|
||||
var trueFirst: Int
|
||||
Log.e("getVerses", "First: $first count: $count")
|
||||
val verses: MutableList<String> = linkedListOf()
|
||||
val trueCount: Int
|
||||
val trueFirst: Int
|
||||
when {
|
||||
first < 0 - count -> return ""
|
||||
first < 0 -> {
|
||||
@ -45,7 +44,7 @@ class BibleViewClient(val b: Book, val lookup: VerseLookupService,
|
||||
for (i in trueFirst..trueFirst + trueCount - 1) {
|
||||
verses.add(getVerse(i))
|
||||
}
|
||||
Log.e("getVerses", "return verses size: " + verses.size.toString())
|
||||
Log.e("getVerses", "return verses size: ${verses.size}")
|
||||
return verses.toString()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user