mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +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
|
// update directories and media files in the local db, delete invalid items
|
||||||
updateDBDirectory(directory)
|
updateDBDirectory(directory)
|
||||||
if (!directory.isRecycleBin()) {
|
if (!directory.isRecycleBin()) {
|
||||||
mediaDB.insertAll(curMedia)
|
Thread {
|
||||||
|
mediaDB.insertAll(curMedia)
|
||||||
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
getCachedMedia(directory.path, getVideosOnly, getImagesOnly) {
|
getCachedMedia(directory.path, getVideosOnly, getImagesOnly) {
|
||||||
|
@ -1029,10 +1031,13 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
dirs.add(newDir)
|
dirs.add(newDir)
|
||||||
setupAdapter(dirs)
|
setupAdapter(dirs)
|
||||||
try {
|
try {
|
||||||
directoryDao.insert(newDir)
|
// make sure to create a new thread for these operations, dont just use the common bg thread
|
||||||
if (folder != RECYCLE_BIN) {
|
Thread {
|
||||||
mediaDB.insertAll(newMedia)
|
directoryDao.insert(newDir)
|
||||||
}
|
if (folder != RECYCLE_BIN) {
|
||||||
|
mediaDB.insertAll(newMedia)
|
||||||
|
}
|
||||||
|
}.start()
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -873,7 +873,9 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
if (!isFromCache) {
|
if (!isFromCache) {
|
||||||
val mediaToInsert = (mMedia).filter { it is Medium && it.deletedTS == 0L }.map { it as Medium }
|
val mediaToInsert = (mMedia).filter { it is Medium && it.deletedTS == 0L }.map { it as Medium }
|
||||||
try {
|
try {
|
||||||
mediaDB.insertAll(mediaToInsert)
|
Thread {
|
||||||
|
mediaDB.insertAll(mediaToInsert)
|
||||||
|
}.start()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue