From b1ecf8a404382d2bda7f586b63a47507730d73ee Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Mon, 29 Dec 2014 13:34:50 -0500 Subject: [PATCH] Autoscroll to the last chapter Currently uses the last chapter loaded, not the last chapter on screen, so may not be 100% accurate. Resolves issue #7. --- .../activity/viewer/BibleViewerPreferences.java | 4 ++++ .../org/bspeice/minimalbible/activity/viewer/BibleView.kt | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewerPreferences.java b/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewerPreferences.java index 148bfc5..dcd2813 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewerPreferences.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewerPreferences.java @@ -17,4 +17,8 @@ public interface BibleViewerPreferences { int baseTextSize(); void baseTextSize(int baseTextSize); + + int currentChapter(); + + void currentChapter(int currentChapter); } diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleView.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleView.kt index 70a41d6..84db172 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleView.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleView.kt @@ -39,6 +39,7 @@ class BibleView(val ctx: Context, val attrs: AttributeSet) : LinearLayout(ctx, a val adapter = BookAdapter(b, prefs) adapter.bindScrollHandler(scrollPublisher, layoutManager) bibleContent setAdapter adapter + bibleContent scrollToPosition prefs.currentChapter() } } @@ -110,8 +111,10 @@ class BookAdapter(val b: Book, val prefs: BibleViewerPreferences) /** * Bind an existing view to its chapter content */ - override fun onBindViewHolder(view: PassageView, position: Int) = - view bind chapterList[position] + override fun onBindViewHolder(view: PassageView, position: Int) { + prefs.currentChapter(position) + return view bind chapterList[position] + } /** * Get the number of chapters in the book