mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-06-05 21:59:19 +02:00
make sure to always create a new thread for inserting some things in db
This commit is contained in:
@@ -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) {
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user