From 4e7393653bd7a52c5d79f0162eb1e963d91c3efd Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Tue, 25 Nov 2014 22:49:30 -0500 Subject: [PATCH] RecyclerView now loads the text It's actually surprisingly speedy, I'm impressed. This may just actually work, only thing left to do is implement the infinite scroll, and I'll have something worth testing... So much easier than maintaining the JS build... --- .../minimalbible/activity/viewer/BookAdapter.kt | 6 ++++-- .../service/format/osisparser/OsisParser.kt | 11 ++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BookAdapter.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BookAdapter.kt index c904d66..b7d7a0e 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BookAdapter.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BookAdapter.kt @@ -8,6 +8,7 @@ import android.view.View import android.view.LayoutInflater import org.bspeice.minimalbible.R import android.widget.TextView +import org.bspeice.minimalbible.service.format.osisparser.OsisParser /** * Adapter used for displaying a book @@ -25,7 +26,7 @@ class BookAdapter(val b: Book) : RecyclerView.Adapter() { .inflate(R.layout.viewer_passage_view, parent, false) val passage = PassageView(emptyView) - passage.v setText "1" +// passage.v setText o.getVerse(b, position).content return passage } @@ -33,7 +34,8 @@ class BookAdapter(val b: Book) : RecyclerView.Adapter() { * Bind an existing view */ override fun onBindViewHolder(view: PassageView, position: Int) { - view.v setText "${Integer.parseInt(view.v.getText() as String) + 1}" + val o = OsisParser() + view.v setText o.getVerse(b, position).content } /** diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/service/format/osisparser/OsisParser.kt b/app/src/main/kotlin/org/bspeice/minimalbible/service/format/osisparser/OsisParser.kt index 76738ee..bb31258 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/service/format/osisparser/OsisParser.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/service/format/osisparser/OsisParser.kt @@ -8,6 +8,8 @@ import org.crosswire.jsword.book.OSISUtil import org.bspeice.minimalbible.SafeValDelegate import org.crosswire.jsword.book.BookData import org.crosswire.jsword.book.Book +import org.crosswire.jsword.book.getVersification +import kotlin.properties.Delegates /** * Created by bspeice on 9/10/14. @@ -17,7 +19,7 @@ class OsisParser() : DefaultHandler() { // Don't pass a verse as part of the constructor, but still guarantee // that it will exist - var verseContent: VerseContent by SafeValDelegate() + var verseContent: VerseContent by Delegates.notNull() // TODO: Implement a stack to keep min API 8 val doWrite = ArrayDeque() @@ -29,6 +31,13 @@ class OsisParser() : DefaultHandler() { return verseContent.json } + fun getVerse(b: Book, v: Int): VerseContent { + val verse = b.getVersification().decodeOrdinal(v) + verseContent = VerseContent(verse) + BookData(b, verse).getSAXEventProvider() provideSAXEvents this + return verseContent + } + override fun startElement(uri: String, localName: String, qName: String, attributes: Attributes) { when (localName) {