mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
avoid fetching the same folder twice, or after exiting the app
This commit is contained in:
parent
e465f73f9b
commit
0cfcba6c8f
1 changed files with 7 additions and 4 deletions
|
@ -73,6 +73,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
private var mTempShowHiddenHandler = Handler()
|
||||
private var mZoomListener: MyRecyclerView.MyZoomListener? = null
|
||||
private var mSearchMenuItem: MenuItem? = null
|
||||
private var mLastMediaFetcher: MediaFetcher? = null
|
||||
private var mDirs = ArrayList<Directory>()
|
||||
|
||||
private var mStoredAnimateGifs = true
|
||||
|
@ -245,6 +246,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
unregisterFileUpdateListener()
|
||||
|
||||
if (!config.showAll) {
|
||||
mLastMediaFetcher?.shouldStop = true
|
||||
GalleryDatabase.destroyInstance()
|
||||
}
|
||||
}
|
||||
|
@ -881,7 +883,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
}
|
||||
|
||||
// cached folders have been loaded, recheck folders one by one starting with the first displayed
|
||||
val mediaFetcher = MediaFetcher(applicationContext)
|
||||
mLastMediaFetcher?.shouldStop = true
|
||||
mLastMediaFetcher = MediaFetcher(applicationContext)
|
||||
val getImagesOnly = mIsPickImageIntent || mIsGetImageContentIntent
|
||||
val getVideosOnly = mIsPickVideoIntent || mIsGetVideoContentIntent
|
||||
val hiddenString = getString(R.string.hidden)
|
||||
|
@ -900,7 +903,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
return
|
||||
}
|
||||
|
||||
val curMedia = mediaFetcher.getFilesFrom(directory.path, getImagesOnly, getVideosOnly, getProperDateTaken, getProperFileSize, favoritePaths, false)
|
||||
val curMedia = mLastMediaFetcher!!.getFilesFrom(directory.path, getImagesOnly, getVideosOnly, getProperDateTaken, getProperFileSize, favoritePaths, false)
|
||||
val newDir = if (curMedia.isEmpty()) {
|
||||
if (directory.path != tempFolderPath) {
|
||||
dirPathsToRemove.add(directory.path)
|
||||
|
@ -955,7 +958,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
} catch (ignored: Exception) {
|
||||
}
|
||||
|
||||
val foldersToScan = mediaFetcher.getFoldersToScan()
|
||||
val foldersToScan = mLastMediaFetcher!!.getFoldersToScan()
|
||||
foldersToScan.add(FAVORITES)
|
||||
if (config.showRecycleBinAtFolders) {
|
||||
foldersToScan.add(RECYCLE_BIN)
|
||||
|
@ -973,7 +976,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
return
|
||||
}
|
||||
|
||||
val newMedia = mediaFetcher.getFilesFrom(folder, getImagesOnly, getVideosOnly, getProperDateTaken, getProperFileSize, favoritePaths, false)
|
||||
val newMedia = mLastMediaFetcher!!.getFilesFrom(folder, getImagesOnly, getVideosOnly, getProperDateTaken, getProperFileSize, favoritePaths, false)
|
||||
if (newMedia.isEmpty()) {
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue