refresh the folders at changing view type

This commit is contained in:
tibbi 2017-09-29 21:47:27 +02:00
parent da00ed8422
commit 9947d661a3

View file

@ -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) {