mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-24 17:08:18 -05:00
Fix infinite scroll getting thrown into an infinite loop...
Ironic, no?
This commit is contained in:
parent
b842ee1933
commit
2ee16ceb4f
@ -26,9 +26,24 @@ class BibleViewClient(b: Book, lookup: VerseLookupService) : WebViewClient() {
|
|||||||
JavascriptInterface fun getVerses(first: Int, count: Int): String {
|
JavascriptInterface fun getVerses(first: Int, count: Int): String {
|
||||||
Log.e("getVerses", "First: " + first + " count: " + count)
|
Log.e("getVerses", "First: " + first + " count: " + count)
|
||||||
val verses: MutableList<String> = ArrayList<String>()
|
val verses: MutableList<String> = ArrayList<String>()
|
||||||
for (i in first..first + count - 1) {
|
var trueCount: Int
|
||||||
|
var trueFirst: Int
|
||||||
|
when {
|
||||||
|
first < 0 - count -> return ""
|
||||||
|
first < 0 -> {
|
||||||
|
trueCount = count + first // Equivalent to count - abs(first)
|
||||||
|
trueFirst = 0
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
trueCount = count
|
||||||
|
trueFirst = first
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i in trueFirst..trueFirst + trueCount - 1) {
|
||||||
verses.add(getVerse(i))
|
verses.add(getVerse(i))
|
||||||
}
|
}
|
||||||
|
Log.e("getVerses", "return verses size: " + verses.size.toString())
|
||||||
return verses.toString()
|
return verses.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,13 +17,16 @@ class OsisParser(v: Verse) : DefaultHandler() {
|
|||||||
|
|
||||||
// Android Studio complains about compilation, but the method
|
// Android Studio complains about compilation, but the method
|
||||||
// has @NotNull annotations, so we program for those.
|
// has @NotNull annotations, so we program for those.
|
||||||
override fun startElement(uri: String, localName: String, qName: String, attributes: Attributes) {
|
override fun startElement(uri: String, localName: String,
|
||||||
|
qName: String, attributes: Attributes) {
|
||||||
if (localName.equals(OSISUtil.OSIS_ELEMENT_VERSE))
|
when (localName) {
|
||||||
doWrite.push(true)
|
OSISUtil.OSIS_ELEMENT_VERSE -> doWrite.push(true)
|
||||||
else
|
else -> {
|
||||||
doWrite.push(false)
|
doWrite.push(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Android Studio complains about compilation, but the method
|
// Android Studio complains about compilation, but the method
|
||||||
// has @NotNull annotations, so we program for those.
|
// has @NotNull annotations, so we program for those.
|
||||||
override fun endElement(uri: String?, localName: String, qName: String) {
|
override fun endElement(uri: String?, localName: String, qName: String) {
|
||||||
|
Loading…
Reference in New Issue
Block a user