Skip setting suspended Apps if the list was not changed

This commit is contained in:
Jonas Lochmann 2019-08-26 00:00:00 +00:00
parent 338a695019
commit 30783d3d2b
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36

View file

@ -106,7 +106,7 @@ class SuspendAppsLogic(private val appLogic: AppLogic) {
} else {
liveDataFromValue(emptyList())
}
}
}.ignoreUnchanged()
private fun getAppsWithCategories(packageNames: List<String>, data: RealCategoryData, blockingAtActivityLevel: Boolean): Map<String, Set<String>> {
val categoryForUnassignedApps = if (data.categories.find { it.id == data.categoryForUnassignedApps } != null) data.categoryForUnassignedApps else null
@ -146,11 +146,13 @@ class SuspendAppsLogic(private val appLogic: AppLogic) {
}
}
private fun applySuspendedApps(packageNames: List<String>) {
appLogic.platformIntegration.stopSuspendingForAllApps()
appLogic.platformIntegration.setSuspendedApps(packageNames, true)
}
init {
realAppsToBlock.observeForever { appsToBlock ->
appLogic.platformIntegration.stopSuspendingForAllApps()
appLogic.platformIntegration.setSuspendedApps(appsToBlock, true)
}
realAppsToBlock.observeForever { appsToBlock -> applySuspendedApps(appsToBlock) }
}
}