From 0e60aca74c52c5bc55918f12043baeb7a8a34cdc Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 19 Feb 2018 18:08:26 +0100 Subject: [PATCH] add some helper functions for getting fastscroller bubble text --- .../simplemobiletools/gallery/activities/MainActivity.kt | 6 ++++-- .../simplemobiletools/gallery/activities/MediaActivity.kt | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 3c59a8361..ecbf4c525 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -619,16 +619,18 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { if (allowHorizontalScroll) { directories_horizontal_fastscroller.allowBubbleDisplay = config.showInfoBubble directories_horizontal_fastscroller.setViews(directories_grid, directories_refresh_layout) { - directories_horizontal_fastscroller.updateBubbleText(mDirs[it].getBubbleText()) + directories_horizontal_fastscroller.updateBubbleText(getBubbleTextItem(it)) } } else { directories_vertical_fastscroller.allowBubbleDisplay = config.showInfoBubble directories_vertical_fastscroller.setViews(directories_grid, directories_refresh_layout) { - directories_vertical_fastscroller.updateBubbleText(mDirs[it].getBubbleText()) + directories_vertical_fastscroller.updateBubbleText(getBubbleTextItem(it)) } } } + private fun getBubbleTextItem(index: Int) = getRecyclerAdapter().dirs.getOrNull(index)?.getBubbleText() ?: "" + private fun checkLastMediaChanged() { if (isActivityDestroyed()) return diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 82d8990ad..9ce048b91 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -334,16 +334,18 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { if (allowHorizontalScroll) { media_horizontal_fastscroller.allowBubbleDisplay = config.showInfoBubble media_horizontal_fastscroller.setViews(media_grid, media_refresh_layout) { - media_horizontal_fastscroller.updateBubbleText(mMedia[it].getBubbleText()) + media_horizontal_fastscroller.updateBubbleText(getBubbleTextItem(it)) } } else { media_vertical_fastscroller.allowBubbleDisplay = config.showInfoBubble media_vertical_fastscroller.setViews(media_grid, media_refresh_layout) { - media_vertical_fastscroller.updateBubbleText(mMedia[it].getBubbleText()) + media_vertical_fastscroller.updateBubbleText(getBubbleTextItem(it)) } } } + private fun getBubbleTextItem(index: Int) = getRecyclerAdapter().media.getOrNull(index)?.getBubbleText() ?: "" + private fun checkLastMediaChanged() { if (isActivityDestroyed()) return