Don't repeat unnecessary work onResume or onStart

This commit is contained in:
MM20 2022-01-30 14:04:25 +01:00
parent 44fac5f157
commit 6e5191bb9e
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
14 changed files with 15 additions and 15 deletions

View File

@ -89,7 +89,7 @@ class ApplicationDetailRepresentation : Representation, KoinComponent {
notificationView.layoutTransition = ChangingLayoutTransition()
job = rootView.scope.launch {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
launch {
iconRepository.getIcon(application, (84 * rootView.dp).toInt())
.collectLatest {

View File

@ -59,7 +59,7 @@ class BasicGridRepresentation : Representation, KoinComponent {
shape = LauncherIconView.currentShape
job = rootView.scope.launch {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
launch {
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
.collectLatest {

View File

@ -56,7 +56,7 @@ class ContactDetailRepresentation : Representation, KoinComponent {
icon = iconRepository.getIconIfCached(contact)
shape = LauncherIconView.currentShape
job = rootView.scope.launch {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
launch {
iconRepository.getIcon(contact, (84 * rootView.dp).toInt())
.collectLatest {

View File

@ -40,7 +40,7 @@ class ContactListRepresentation : Representation, KoinComponent {
icon = iconRepository.getIconIfCached(contact)
shape = LauncherIconView.currentShape
job = rootView.scope.launch {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
launch {
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
.collectLatest {

View File

@ -51,7 +51,7 @@ class FileDetailRepresentation : Representation, KoinComponent {
icon = iconRepository.getIconIfCached(file)
shape = LauncherIconView.currentShape
job = rootView.scope.launch {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
launch {
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
.collectLatest {

View File

@ -47,7 +47,7 @@ class FileListRepresentation : Representation, KoinComponent {
icon = iconRepository.getIconIfCached(file)
shape = LauncherIconView.currentShape
job = rootView.scope.launch {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
launch {
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
.collectLatest {

View File

@ -44,7 +44,7 @@ class SearchGridView : ViewGroup, KoinComponent {
super.onAttachedToWindow()
job?.cancel()
lifecycleScope.launch {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
columnCountPreference.collectLatest {
columnCount = it
}

View File

@ -49,7 +49,7 @@ class AppShortcutDetailRepresentation : Representation, KoinComponent {
icon = iconRepository.getIconIfCached(appShortcut)
shape = LauncherIconView.currentShape
job = rootView.scope.launch {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
launch {
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
.collectLatest {

View File

@ -76,7 +76,7 @@ class WebsiteDetailRepresentation : Representation, KoinComponent {
icon = iconRepository.getIconIfCached(website)
shape = LauncherIconView.currentShape
job = rootView.scope.launch {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
launch {
iconRepository.getIcon(website, (84 * rootView.dp).toInt())
.collectLatest {

View File

@ -80,7 +80,7 @@ class WebsiteListRepresentation : Representation, KoinComponent {
icon = iconRepository.getIconIfCached(website)
shape = LauncherIconView.currentShape
job = rootView.scope.launch {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
launch {
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
.collectLatest {

View File

@ -37,7 +37,7 @@ open class InnerCardView @JvmOverloads constructor(
super.onAttachedToWindow()
job?.cancel()
job = lifecycleScope.launch {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
dataStore.data.map { it.cards.radius }.distinctUntilChanged().collectLatest {
radius = it * dp
}

View File

@ -82,7 +82,7 @@ open class LauncherCardView @JvmOverloads constructor(
super.onAttachedToWindow()
job?.cancel()
job = lifecycleScope.launch {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
dataStore.data.map { it.cards }.distinctUntilChanged().collectLatest {
currentCardStyle = it
if (!overrideBackgroundOpacity) {

View File

@ -372,7 +372,7 @@ class SwipeCardView @JvmOverloads constructor(
super.onAttachedToWindow()
job?.cancel()
job = lifecycleScope.launch {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
dataStore.data.map { it.cards.radius }.distinctUntilChanged().collectLatest {
radius = it * dp
}

View File

@ -251,7 +251,7 @@ class FavoriteToolbarAction(val context: Context, val item: Searchable) : Toolba
(context as LifecycleOwner).apply {
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
repeatOnLifecycle(Lifecycle.State.CREATED) {
repository.isPinned(item).collectLatest {
isPinned = it
}
@ -290,7 +290,7 @@ class VisibilityToolbarAction(val context: Context, val item: Searchable) : Tool
(context as LifecycleOwner).apply {
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
repeatOnLifecycle(Lifecycle.State.CREATED) {
repository.isHidden(item).collectLatest {
isHidden = it
}