Allows cleaning up on App Pause to perform separately from memory pruning functions

This commit is contained in:
Vitor Pamplona
2023-08-27 12:10:12 -04:00
parent de1f13d64c
commit 43ac1bf555
2 changed files with 7 additions and 2 deletions

View File

@@ -115,7 +115,11 @@ object ServiceManager {
Client.disconnect() Client.disconnect()
} }
fun cleanUp() { fun cleanObservers() {
LocalCache.cleanObservers()
}
fun trimMemory() {
LocalCache.cleanObservers() LocalCache.cleanObservers()
val accounts = LocalPreferences.allLocalAccountNPubs().mapNotNull { decodePublicKeyAsHexOrNull(it) }.toSet() val accounts = LocalPreferences.allLocalAccountNPubs().mapNotNull { decodePublicKeyAsHexOrNull(it) }.toSet()

View File

@@ -103,6 +103,7 @@ class MainActivity : AppCompatActivity() {
} }
override fun onPause() { override fun onPause() {
ServiceManager.cleanObservers()
// if (BuildConfig.DEBUG) { // if (BuildConfig.DEBUG) {
debugState(this) debugState(this)
// } // }
@@ -127,7 +128,7 @@ class MainActivity : AppCompatActivity() {
super.onTrimMemory(level) super.onTrimMemory(level)
println("Trim Memory $level") println("Trim Memory $level")
GlobalScope.launch(Dispatchers.Default) { GlobalScope.launch(Dispatchers.Default) {
ServiceManager.cleanUp() ServiceManager.trimMemory()
} }
} }