From 799d8e263779760b6db83870beebfe2e84bf315e Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Thu, 27 Nov 2014 21:23:28 -0500 Subject: [PATCH] Use first {} over filter {} --- .../minimalbible/activity/viewer/BookAdapter.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 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 a1dae49..0c6a64e 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 @@ -77,12 +77,16 @@ class BookAdapter(val b: Book, val lookup: VerseLookup) lM: RecyclerView.LayoutManager) { provider subscribe { val event = it - chapterList.withIndices() - .filter { - event.b == it.second.bibleBook && - event.chapter == it.second.chapter - } - .forEach { lM scrollToPosition it.first } + lM scrollToPosition + // Get all objects in the form (index, object) + chapterList.withIndices() + // Get one that matches our book and chapter + .first { + event.b == it.second.bibleBook && + event.chapter == it.second.chapter + } + // And get that index value to scroll to + .first } } }