mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
make sure to always create a new thread for inserting some things in db
This commit is contained in:
parent
963fd57113
commit
462182271d
2 changed files with 13 additions and 6 deletions
|
@ -955,7 +955,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
// update directories and media files in the local db, delete invalid items
|
||||
updateDBDirectory(directory)
|
||||
if (!directory.isRecycleBin()) {
|
||||
Thread {
|
||||
mediaDB.insertAll(curMedia)
|
||||
}.start()
|
||||
}
|
||||
|
||||
getCachedMedia(directory.path, getVideosOnly, getImagesOnly) {
|
||||
|
@ -1029,10 +1031,13 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
dirs.add(newDir)
|
||||
setupAdapter(dirs)
|
||||
try {
|
||||
// make sure to create a new thread for these operations, dont just use the common bg thread
|
||||
Thread {
|
||||
directoryDao.insert(newDir)
|
||||
if (folder != RECYCLE_BIN) {
|
||||
mediaDB.insertAll(newMedia)
|
||||
}
|
||||
}.start()
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -873,7 +873,9 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
if (!isFromCache) {
|
||||
val mediaToInsert = (mMedia).filter { it is Medium && it.deletedTS == 0L }.map { it as Medium }
|
||||
try {
|
||||
Thread {
|
||||
mediaDB.insertAll(mediaToInsert)
|
||||
}.start()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue