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 67e00e98a..e3017393e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -343,7 +343,12 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { itemClicked(it.path) } - directories_grid.adapter = adapter + val currAdapter = directories_grid.adapter + if (currAdapter != null) { + (currAdapter as DirectoryAdapter).updateDirs(mDirs) + } else { + directories_grid.adapter = adapter + } directories_fastscroller.setViews(directories_grid, directories_refresh_layout) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index cdaf426c9..2acc9dd99 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -27,7 +27,7 @@ import kotlinx.android.synthetic.main.directory_tmb.view.* import java.io.File import java.util.* -class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList, val listener: DirOperationsListener?, val itemClick: (Directory) -> Unit) : +class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList, val listener: DirOperationsListener?, val itemClick: (Directory) -> Unit) : RecyclerView.Adapter() { val multiSelector = MultiSelector() @@ -345,6 +345,11 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList) { + dirs = newDirs + notifyDataSetChanged() + } + fun selectItem(pos: Int) { toggleItemSelection(true, pos) }