Handle navigating on clicking a search item

This commit is contained in:
Bradlee Speice
2015-04-02 20:26:29 -04:00
parent 8533cf523c
commit 4b3050c8cd
4 changed files with 88 additions and 12 deletions

View File

@ -1,8 +1,17 @@
package org.bspeice.minimalbible.activity.viewer
import org.crosswire.jsword.book.Book
import org.crosswire.jsword.book.getVersification
import org.crosswire.jsword.passage.Verse
import org.crosswire.jsword.versification.BibleBook
/**
* Created by bspeice on 11/26/14.
*/
data class BookScrollEvent(val b: BibleBook, val chapter: Int) {}
data class BookScrollEvent(val b: BibleBook, val chapter: Int) {
constructor(v: Verse) : this(v.getBook(), v.getChapter()) {
}
constructor(b: Book, ordinal: Int) : this(b.getVersification().decodeOrdinal(ordinal)) {
}
}

View File

@ -0,0 +1,27 @@
package org.bspeice.minimalbible.activity.viewer
import android.content.Context
import android.content.Intent
import org.crosswire.jsword.passage.Verse
/**
* Created by bspeice on 4/2/15.
*/
class ViewerIntent() {
companion object {
val VERSE_RESULT_KEY = "VERSE_RESULT"
fun fromSearchResult(ctx: Context, verse: Verse): Intent {
val i = Intent(ctx, javaClass<BibleViewer>())
i.putExtra(VERSE_RESULT_KEY, verse.getOrdinal())
return i
}
/**
* Attempt to get the result of a search out of the intent
* Returns -1 if no search result was found
*/
fun decodeSearchResult(i: Intent) = i.getIntExtra(VERSE_RESULT_KEY, -1)
}
}