remove mDirs from the MainActivity

This commit is contained in:
tibbi 2018-04-24 09:42:13 +02:00
parent 0762918673
commit b4e1e0c097
2 changed files with 8 additions and 17 deletions

View file

@ -42,8 +42,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
private val LAST_MEDIA_CHECK_PERIOD = 3000L private val LAST_MEDIA_CHECK_PERIOD = 3000L
private val NEW_APP_PACKAGE = "com.simplemobiletools.clock" private val NEW_APP_PACKAGE = "com.simplemobiletools.clock"
lateinit var mDirs: ArrayList<Directory>
private var mIsPickImageIntent = false private var mIsPickImageIntent = false
private var mIsPickVideoIntent = false private var mIsPickVideoIntent = false
private var mIsGetImageContentIntent = false private var mIsGetImageContentIntent = false
@ -86,7 +84,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
removeTempFolder() removeTempFolder()
directories_refresh_layout.setOnRefreshListener { getDirectories() } directories_refresh_layout.setOnRefreshListener { getDirectories() }
mDirs = ArrayList()
storeStateVariables() storeStateVariables()
checkWhatsNewDialog() checkWhatsNewDialog()
@ -287,7 +284,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
if (config.directorySorting and SORT_BY_DATE_MODIFIED > 0 || config.directorySorting and SORT_BY_DATE_TAKEN > 0) { if (config.directorySorting and SORT_BY_DATE_MODIFIED > 0 || config.directorySorting and SORT_BY_DATE_TAKEN > 0) {
getDirectories() getDirectories()
} else { } else {
gotDirectories(mDirs) gotDirectories(getCurrentlyDisplayedDirs())
} }
} }
} }
@ -417,7 +414,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
FilePickerDialog(this, internalStoragePath, false, config.shouldShowHidden) { FilePickerDialog(this, internalStoragePath, false, config.shouldShowHidden) {
CreateNewFolderDialog(this, it) { CreateNewFolderDialog(this, it) {
config.tempFolderPath = it config.tempFolderPath = it
gotDirectories(addTempFolderIfNeeded(mDirs)) gotDirectories(addTempFolderIfNeeded(getCurrentlyDisplayedDirs()))
} }
} }
} }
@ -757,16 +754,10 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
} }
override fun recheckPinnedFolders() { override fun recheckPinnedFolders() {
gotDirectories(movePinnedDirectoriesToFront(mDirs)) gotDirectories(movePinnedDirectoriesToFront(getCurrentlyDisplayedDirs()))
} }
override fun updateDirectories(directories: ArrayList<Directory>, refreshList: Boolean) { override fun updateDirectories(directories: ArrayList<Directory>) {
if (refreshList) {
gotDirectories(directories)
} else {
mDirs = directories
}
Thread { Thread {
storeDirectoryItems(directories) storeDirectoryItems(directories)
removeInvalidDirectories() removeInvalidDirectories()

View file

@ -171,7 +171,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
tmb = File(it, tmb.getFilenameFromPath()).absolutePath tmb = File(it, tmb.getFilenameFromPath()).absolutePath
} }
updateDirs(dirs) updateDirs(dirs)
listener?.updateDirectories(dirs.toList() as ArrayList, false) listener?.updateDirectories(dirs.toList() as ArrayList)
} }
} }
} }
@ -209,7 +209,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
dirs.forEach { dirs.forEach {
it.name = activity.checkAppendingHidden(it.path, hidden, includedFolders) it.name = activity.checkAppendingHidden(it.path, hidden, includedFolders)
} }
listener?.updateDirectories(dirs.toList() as ArrayList, false) listener?.updateDirectories(dirs.toList() as ArrayList)
activity.runOnUiThread { activity.runOnUiThread {
updateDirs(dirs) updateDirs(dirs)
} }
@ -246,7 +246,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
dirs = newDirs dirs = newDirs
finishActMode() finishActMode()
fastScroller?.measureRecyclerView() fastScroller?.measureRecyclerView()
listener?.updateDirectories(newDirs, false) listener?.updateDirectories(newDirs)
} }
} }
} }
@ -440,6 +440,6 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
fun recheckPinnedFolders() fun recheckPinnedFolders()
fun updateDirectories(directories: ArrayList<Directory>, refreshList: Boolean) fun updateDirectories(directories: ArrayList<Directory>)
} }
} }