fix media inserting ConcurrentModificationException in a proper way

This commit is contained in:
tibbi 2018-04-23 13:31:26 +02:00
parent 3aaa17a02d
commit 4f724786b2

View file

@ -633,14 +633,12 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
}
private fun gotMedia(media: ArrayList<Medium>, isFromCache: Boolean = false) {
val mediaToInsert = media.clone() as ArrayList<Medium>
Thread {
mLatestMediaId = getLatestMediaId()
mLatestMediaDateId = getLatestMediaByDateId()
if (!isFromCache) {
try {
galleryDB.MediumDao().insertAll(media)
} catch (e: ConcurrentModificationException) {
}
galleryDB.MediumDao().insertAll(mediaToInsert)
}
}.start()