mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
moving the directory refreshing function in a context extension
This commit is contained in:
parent
e9cee05b9d
commit
1445434930
2 changed files with 19 additions and 19 deletions
|
@ -806,3 +806,19 @@ fun Context.createDirectoryFromMedia(path: String, curMedia: ArrayList<Medium>,
|
||||||
val mediaTypes = curMedia.getDirMediaTypes()
|
val mediaTypes = curMedia.getDirMediaTypes()
|
||||||
return Directory(null, path, thumbnail, dirName, curMedia.size, lastModified, dateTaken, size, getPathLocation(path), mediaTypes)
|
return Directory(null, path, thumbnail, dirName, curMedia.size, lastModified, dateTaken, size, getPathLocation(path), mediaTypes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Context.updateDirectoryPath(path: String) {
|
||||||
|
val mediaFetcher = MediaFetcher(applicationContext)
|
||||||
|
val getImagesOnly = false
|
||||||
|
val getVideosOnly = false
|
||||||
|
val hiddenString = getString(R.string.hidden)
|
||||||
|
val albumCovers = config.parseAlbumCovers()
|
||||||
|
val includedFolders = config.includedFolders
|
||||||
|
val isSortingAscending = config.directorySorting and SORT_DESCENDING == 0
|
||||||
|
val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0
|
||||||
|
val getProperFileSize = config.directorySorting and SORT_BY_SIZE != 0
|
||||||
|
val favoritePaths = getFavoritePaths()
|
||||||
|
val curMedia = mediaFetcher.getFilesFrom(path, getImagesOnly, getVideosOnly, getProperDateTaken, getProperFileSize, favoritePaths, false)
|
||||||
|
val directory = createDirectoryFromMedia(path, curMedia, albumCovers, hiddenString, includedFolders, isSortingAscending, getProperFileSize)
|
||||||
|
updateDBDirectory(directory, galleryDB.DirectoryDao())
|
||||||
|
}
|
||||||
|
|
|
@ -14,12 +14,8 @@ import android.os.Handler
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import com.simplemobiletools.commons.extensions.getParentPath
|
import com.simplemobiletools.commons.extensions.getParentPath
|
||||||
import com.simplemobiletools.commons.extensions.getStringValue
|
import com.simplemobiletools.commons.extensions.getStringValue
|
||||||
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN
|
import com.simplemobiletools.gallery.pro.extensions.addPathToDB
|
||||||
import com.simplemobiletools.commons.helpers.SORT_BY_SIZE
|
import com.simplemobiletools.gallery.pro.extensions.updateDirectoryPath
|
||||||
import com.simplemobiletools.commons.helpers.SORT_DESCENDING
|
|
||||||
import com.simplemobiletools.gallery.pro.R
|
|
||||||
import com.simplemobiletools.gallery.pro.extensions.*
|
|
||||||
import com.simplemobiletools.gallery.pro.helpers.MediaFetcher
|
|
||||||
|
|
||||||
// based on https://developer.android.com/reference/android/app/job/JobInfo.Builder.html#addTriggerContentUri(android.app.job.JobInfo.TriggerContentUri)
|
// based on https://developer.android.com/reference/android/app/job/JobInfo.Builder.html#addTriggerContentUri(android.app.job.JobInfo.TriggerContentUri)
|
||||||
@TargetApi(Build.VERSION_CODES.N)
|
@TargetApi(Build.VERSION_CODES.N)
|
||||||
|
@ -100,19 +96,7 @@ class NewPhotoFetcher : JobService() {
|
||||||
|
|
||||||
Thread {
|
Thread {
|
||||||
affectedFolderPaths.forEach {
|
affectedFolderPaths.forEach {
|
||||||
val mediaFetcher = MediaFetcher(applicationContext)
|
updateDirectoryPath(it)
|
||||||
val getImagesOnly = false
|
|
||||||
val getVideosOnly = false
|
|
||||||
val hiddenString = getString(R.string.hidden)
|
|
||||||
val albumCovers = config.parseAlbumCovers()
|
|
||||||
val includedFolders = config.includedFolders
|
|
||||||
val isSortingAscending = config.directorySorting and SORT_DESCENDING == 0
|
|
||||||
val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0
|
|
||||||
val getProperFileSize = config.directorySorting and SORT_BY_SIZE != 0
|
|
||||||
val favoritePaths = getFavoritePaths()
|
|
||||||
val curMedia = mediaFetcher.getFilesFrom(it, getImagesOnly, getVideosOnly, getProperDateTaken, getProperFileSize, favoritePaths, false)
|
|
||||||
val directory = createDirectoryFromMedia(it, curMedia, albumCovers, hiddenString, includedFolders, isSortingAscending, getProperFileSize)
|
|
||||||
updateDBDirectory(directory, galleryDB.DirectoryDao())
|
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue