From 9947d661a3345b4e21bab2429a01dc4186ea3295 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Sep 2017 21:47:27 +0200 Subject: [PATCH] refresh the folders at changing view type --- .../gallery/activities/MainActivity.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 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 4380187b1..57d7dff6c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -182,11 +182,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { else getDirectories() - if (config.viewTypeFolders == VIEW_TYPE_GRID) - setupGridLayoutManager() - else - setupListLayoutManager() - + setupLayoutManager() checkIfColorChanged() } else { ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_PERMISSION) @@ -261,6 +257,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { RadioGroupDialog(this, items, config.viewTypeFolders) { config.viewTypeFolders = it as Int invalidateOptionsMenu() + setupLayoutManager() + directories_grid.adapter = null + setupAdapter() } } @@ -300,6 +299,13 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun getRecyclerAdapter() = (directories_grid.adapter as DirectoryAdapter) + private fun setupLayoutManager() { + if (config.viewTypeFolders == VIEW_TYPE_GRID) + setupGridLayoutManager() + else + setupListLayoutManager() + } + private fun setupGridLayoutManager() { val layoutManager = directories_grid.layoutManager as GridLayoutManager if (config.scrollHorizontally) {