From e4b77eacb01d8d82da94dc320edce70e111b2e38 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 30 Sep 2017 23:56:28 +0200 Subject: [PATCH] fixing some fastscroller glitches --- .../simplemobiletools/gallery/activities/MainActivity.kt | 7 ++++--- .../simplemobiletools/gallery/activities/MediaActivity.kt | 7 ++++--- .../gallery/dialogs/PickDirectoryDialog.kt | 8 +++++--- 3 files changed, 13 insertions(+), 9 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 0ca8e74a9..bbde246e1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -509,15 +509,16 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } private fun setupScrollDirection() { + val allowHorizontalScroll = config.scrollHorizontally && config.viewTypeFolders == VIEW_TYPE_GRID directories_refresh_layout.isEnabled = !config.scrollHorizontally directories_vertical_fastscroller.isHorizontal = false - directories_vertical_fastscroller.beGoneIf(config.scrollHorizontally) + directories_vertical_fastscroller.beGoneIf(allowHorizontalScroll) directories_horizontal_fastscroller.isHorizontal = true - directories_horizontal_fastscroller.beVisibleIf(config.scrollHorizontally) + directories_horizontal_fastscroller.beVisibleIf(allowHorizontalScroll) - if (config.scrollHorizontally) { + if (allowHorizontalScroll) { directories_horizontal_fastscroller.setViews(directories_grid, directories_refresh_layout) } else { directories_vertical_fastscroller.setViews(directories_grid, directories_refresh_layout) 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 678db7f7f..79baeed6a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -169,15 +169,16 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } private fun setupScrollDirection() { + val allowHorizontalScroll = config.scrollHorizontally && config.viewTypeFiles == VIEW_TYPE_GRID media_refresh_layout.isEnabled = !config.scrollHorizontally media_vertical_fastscroller.isHorizontal = false - media_vertical_fastscroller.beGoneIf(config.scrollHorizontally) + media_vertical_fastscroller.beGoneIf(allowHorizontalScroll) media_horizontal_fastscroller.isHorizontal = true - media_horizontal_fastscroller.beVisibleIf(config.scrollHorizontally) + media_horizontal_fastscroller.beVisibleIf(allowHorizontalScroll) - if (config.scrollHorizontally) { + if (allowHorizontalScroll) { media_horizontal_fastscroller.setViews(media_grid, media_refresh_layout) } else { media_vertical_fastscroller.setViews(media_grid, media_refresh_layout) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt index a4e877bad..1d53684cb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt @@ -16,6 +16,7 @@ import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.getCachedDirectories import com.simplemobiletools.gallery.extensions.getSortedDirectories +import com.simplemobiletools.gallery.helpers.VIEW_TYPE_GRID import com.simplemobiletools.gallery.models.Directory import kotlinx.android.synthetic.main.dialog_directory_picker.view.* @@ -23,11 +24,12 @@ class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String, var dialog: AlertDialog var shownDirectories: ArrayList = ArrayList() var view: View = LayoutInflater.from(activity).inflate(R.layout.dialog_directory_picker, null) + var isGridViewType = activity.config.viewTypeFolders == VIEW_TYPE_GRID init { (view.directories_grid.layoutManager as GridLayoutManager).apply { - orientation = if (activity.config.scrollHorizontally) GridLayoutManager.HORIZONTAL else GridLayoutManager.VERTICAL - spanCount = activity.config.dirColumnCnt + orientation = if (activity.config.scrollHorizontally && isGridViewType) GridLayoutManager.HORIZONTAL else GridLayoutManager.VERTICAL + spanCount = if (isGridViewType) activity.config.dirColumnCnt else 1 } dialog = AlertDialog.Builder(activity) @@ -71,7 +73,7 @@ class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String, } } - val scrollHorizontally = activity.config.scrollHorizontally + val scrollHorizontally = activity.config.scrollHorizontally && isGridViewType view.apply { directories_grid.adapter = adapter