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 0d68ab3fb..e1dcac814 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -210,7 +210,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mLoadedInitialPhotos = true mCurrAsyncTask = GetDirectoriesAsynctask(applicationContext, mIsPickVideoIntent || mIsGetVideoContentIntent, mIsPickImageIntent || mIsGetImageContentIntent) { - gotDirectories(it) + addTempFolderIfNeeded(it, false) } mCurrAsyncTask!!.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR) } @@ -315,10 +315,21 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { FilePickerDialog(this, internalStoragePath, false, config.shouldShowHidden) { CreateNewFolderDialog(this, it) { mNewFolderPath = it + addTempFolderIfNeeded(mDirs, true) } } } + private fun addTempFolderIfNeeded(dirs: ArrayList, isFromCache: Boolean) { + val directories = ArrayList() + if (mNewFolderPath.isNotEmpty()) { + val newFolder = Directory(mNewFolderPath, "", mNewFolderPath.getFilenameFromPath(), 0, 0, 0, 0L) + directories.add(newFolder) + } + directories.addAll(dirs) + gotDirectories(directories, isFromCache) + } + private fun increaseColumnCount() { config.dirColumnCnt = ++(directories_grid.layoutManager as GridLayoutManager).spanCount invalidateOptionsMenu() @@ -416,7 +427,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } } - private fun gotDirectories(dirs: ArrayList, isFromCache: Boolean = false) { + private fun gotDirectories(dirs: ArrayList, isFromCache: Boolean) { mLastMediaModified = getLastMediaModified() directories_refresh_layout.isRefreshing = false mIsGettingDirs = false @@ -433,11 +444,12 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { runOnUiThread { setupAdapter() } + storeDirectories() } private fun storeDirectories() { - if (!config.temporarilyShowHidden) { + if (!config.temporarilyShowHidden && mNewFolderPath.isEmpty()) { val directories = Gson().toJson(mDirs) config.directories = directories }