add some cleanup on low memory

doesnt help by much but its here now
This commit is contained in:
Jays2Kings 2022-04-20 21:33:26 -04:00
parent 92b98cef5c
commit 077b5ab916
4 changed files with 24 additions and 0 deletions

View file

@ -20,7 +20,10 @@ import eu.kanade.tachiyomi.data.image.coil.CoilSetup
import eu.kanade.tachiyomi.data.notification.Notifications
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
import eu.kanade.tachiyomi.ui.recents.RecentsPresenter
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
import eu.kanade.tachiyomi.ui.source.SourcePresenter
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil
import eu.kanade.tachiyomi.util.system.notification
import kotlinx.coroutines.flow.launchIn
@ -120,6 +123,13 @@ open class App : Application(), DefaultLifecycleObserver {
MultiDex.install(this)
}
override fun onLowMemory() {
super.onLowMemory()
LibraryPresenter.onLowMemory()
RecentsPresenter.onLowMemory()
SourcePresenter.onLowMemory()
}
protected open fun setupAcra() {
initAcra {
reportFormat = StringFormat.JSON

View file

@ -1132,6 +1132,11 @@ class LibraryPresenter(
private const val randomGroupOfTagsNormal = 1
private const val randomGroupOfTagsNegate = 2
fun onLowMemory() {
lastLibraryItems = null
lastCategories = null
}
suspend fun setSearchSuggestion(
preferences: PreferencesHelper,
db: DatabaseHelper,

View file

@ -505,6 +505,10 @@ class RecentsPresenter(
companion object {
private var lastRecents: List<RecentMangaItem>? = null
fun onLowMemory() {
lastRecents = null
}
const val VIEW_TYPE_GROUP_ALL = 0
const val VIEW_TYPE_UNGROUP_ALL = 1
const val VIEW_TYPE_ONLY_HISTORY = 2

View file

@ -145,5 +145,10 @@ class SourcePresenter(
private var lastSources: List<SourceItem>? = null
private var lastUsedItemRem: SourceItem? = null
fun onLowMemory() {
lastSources = null
lastUsedItemRem = null
}
}
}