Skip to content

Commit

Permalink
better realm instance management
Browse files Browse the repository at this point in the history
  • Loading branch information
Okuro3499 committed Oct 18, 2024
1 parent 7eaf68f commit dca716b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/src/main/java/org/ole/planet/myplanet/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ class MainApplication : Application(), Application.ActivityLifecycleCallbacks {

private fun handleUncaughtException(e: Throwable) {
e.printStackTrace()
runBlocking {
launch(Dispatchers.IO) {
applicationScope.launch(Dispatchers.IO) {
try {
val realm = Realm.getDefaultInstance()
try {
val realm = Realm.getDefaultInstance()
realm.executeTransaction { r ->
val log = r.createObject(RealmApkLog::class.java, "${UUID.randomUUID()}")
val model = UserProfileDbHandler(this@MainApplication).userModel
Expand All @@ -311,10 +311,11 @@ class MainApplication : Application(), Application.ActivityLifecycleCallbacks {
log.type = RealmApkLog.ERROR_TYPE_CRASH
log.setError(e)
}
} finally {
realm.close()
} catch (ex: Exception) {
ex.printStackTrace()
}
} catch (ex: Exception) {
ex.printStackTrace()
}
}

Expand Down

0 comments on commit dca716b

Please sign in to comment.