Use first {} over filter {}

This commit is contained in:
Bradlee Speice 2014-11-27 21:23:28 -05:00
parent fba4e04fdb
commit 799d8e2637

View File

@ -77,12 +77,16 @@ class BookAdapter(val b: Book, val lookup: VerseLookup)
lM: RecyclerView.LayoutManager) { lM: RecyclerView.LayoutManager) {
provider subscribe { provider subscribe {
val event = it val event = it
lM scrollToPosition
// Get all objects in the form (index, object)
chapterList.withIndices() chapterList.withIndices()
.filter { // Get one that matches our book and chapter
.first {
event.b == it.second.bibleBook && event.b == it.second.bibleBook &&
event.chapter == it.second.chapter event.chapter == it.second.chapter
} }
.forEach { lM scrollToPosition it.first } // And get that index value to scroll to
.first
} }
} }
} }