修改realm事物存储逻辑,解决OOM问题

This commit is contained in:
qiji4215
2023-09-11 15:59:56 +08:00
parent dbe81f5bde
commit 30822c7937
23 changed files with 443 additions and 210 deletions

View File

@@ -106,9 +106,10 @@ class TaskDownloadScope(
downloadData.postValue(taskBean)
if (status != FileDownloadStatus.LOADING && status != FileDownloadStatus.IMPORTING) {
val realm = Realm.getDefaultInstance()
realm.executeTransaction {
it.insertOrUpdate(taskBean)
}
realm.beginTransaction()
realm.insertOrUpdate(taskBean)
realm.commitTransaction()
realm.close()
}
}
}
@@ -142,6 +143,7 @@ class TaskDownloadScope(
Log.e("jingo", "数据安装 $it")
if (it == "finish") {
change(FileDownloadStatus.DONE)
Log.e("jingo", "数据安装结束")
withContext(Dispatchers.Main) {
downloadManager.mapController.layerManagerHandler.updateOMDBVectorTileLayer()
}

View File

@@ -84,6 +84,7 @@ class TaskUploadScope(
realm.executeTransaction {
it.copyToRealmOrUpdate(taskBean)
}
realm.close()
}
}
}
@@ -220,7 +221,7 @@ class TaskUploadScope(
}
}
}
realm.close()
}
if (bodyList.size > 0) {