Don't repeat unnecessary work onResume or onStart
This commit is contained in:
parent
44fac5f157
commit
6e5191bb9e
@ -89,7 +89,7 @@ class ApplicationDetailRepresentation : Representation, KoinComponent {
|
|||||||
notificationView.layoutTransition = ChangingLayoutTransition()
|
notificationView.layoutTransition = ChangingLayoutTransition()
|
||||||
|
|
||||||
job = rootView.scope.launch {
|
job = rootView.scope.launch {
|
||||||
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
launch {
|
launch {
|
||||||
iconRepository.getIcon(application, (84 * rootView.dp).toInt())
|
iconRepository.getIcon(application, (84 * rootView.dp).toInt())
|
||||||
.collectLatest {
|
.collectLatest {
|
||||||
|
|||||||
@ -59,7 +59,7 @@ class BasicGridRepresentation : Representation, KoinComponent {
|
|||||||
shape = LauncherIconView.currentShape
|
shape = LauncherIconView.currentShape
|
||||||
|
|
||||||
job = rootView.scope.launch {
|
job = rootView.scope.launch {
|
||||||
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
launch {
|
launch {
|
||||||
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
|
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
|
||||||
.collectLatest {
|
.collectLatest {
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class ContactDetailRepresentation : Representation, KoinComponent {
|
|||||||
icon = iconRepository.getIconIfCached(contact)
|
icon = iconRepository.getIconIfCached(contact)
|
||||||
shape = LauncherIconView.currentShape
|
shape = LauncherIconView.currentShape
|
||||||
job = rootView.scope.launch {
|
job = rootView.scope.launch {
|
||||||
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
launch {
|
launch {
|
||||||
iconRepository.getIcon(contact, (84 * rootView.dp).toInt())
|
iconRepository.getIcon(contact, (84 * rootView.dp).toInt())
|
||||||
.collectLatest {
|
.collectLatest {
|
||||||
|
|||||||
@ -40,7 +40,7 @@ class ContactListRepresentation : Representation, KoinComponent {
|
|||||||
icon = iconRepository.getIconIfCached(contact)
|
icon = iconRepository.getIconIfCached(contact)
|
||||||
shape = LauncherIconView.currentShape
|
shape = LauncherIconView.currentShape
|
||||||
job = rootView.scope.launch {
|
job = rootView.scope.launch {
|
||||||
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
launch {
|
launch {
|
||||||
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
|
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
|
||||||
.collectLatest {
|
.collectLatest {
|
||||||
|
|||||||
@ -51,7 +51,7 @@ class FileDetailRepresentation : Representation, KoinComponent {
|
|||||||
icon = iconRepository.getIconIfCached(file)
|
icon = iconRepository.getIconIfCached(file)
|
||||||
shape = LauncherIconView.currentShape
|
shape = LauncherIconView.currentShape
|
||||||
job = rootView.scope.launch {
|
job = rootView.scope.launch {
|
||||||
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
launch {
|
launch {
|
||||||
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
|
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
|
||||||
.collectLatest {
|
.collectLatest {
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class FileListRepresentation : Representation, KoinComponent {
|
|||||||
icon = iconRepository.getIconIfCached(file)
|
icon = iconRepository.getIconIfCached(file)
|
||||||
shape = LauncherIconView.currentShape
|
shape = LauncherIconView.currentShape
|
||||||
job = rootView.scope.launch {
|
job = rootView.scope.launch {
|
||||||
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
launch {
|
launch {
|
||||||
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
|
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
|
||||||
.collectLatest {
|
.collectLatest {
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class SearchGridView : ViewGroup, KoinComponent {
|
|||||||
super.onAttachedToWindow()
|
super.onAttachedToWindow()
|
||||||
job?.cancel()
|
job?.cancel()
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
columnCountPreference.collectLatest {
|
columnCountPreference.collectLatest {
|
||||||
columnCount = it
|
columnCount = it
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ class AppShortcutDetailRepresentation : Representation, KoinComponent {
|
|||||||
icon = iconRepository.getIconIfCached(appShortcut)
|
icon = iconRepository.getIconIfCached(appShortcut)
|
||||||
shape = LauncherIconView.currentShape
|
shape = LauncherIconView.currentShape
|
||||||
job = rootView.scope.launch {
|
job = rootView.scope.launch {
|
||||||
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
launch {
|
launch {
|
||||||
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
|
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
|
||||||
.collectLatest {
|
.collectLatest {
|
||||||
|
|||||||
@ -76,7 +76,7 @@ class WebsiteDetailRepresentation : Representation, KoinComponent {
|
|||||||
icon = iconRepository.getIconIfCached(website)
|
icon = iconRepository.getIconIfCached(website)
|
||||||
shape = LauncherIconView.currentShape
|
shape = LauncherIconView.currentShape
|
||||||
job = rootView.scope.launch {
|
job = rootView.scope.launch {
|
||||||
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
launch {
|
launch {
|
||||||
iconRepository.getIcon(website, (84 * rootView.dp).toInt())
|
iconRepository.getIcon(website, (84 * rootView.dp).toInt())
|
||||||
.collectLatest {
|
.collectLatest {
|
||||||
|
|||||||
@ -80,7 +80,7 @@ class WebsiteListRepresentation : Representation, KoinComponent {
|
|||||||
icon = iconRepository.getIconIfCached(website)
|
icon = iconRepository.getIconIfCached(website)
|
||||||
shape = LauncherIconView.currentShape
|
shape = LauncherIconView.currentShape
|
||||||
job = rootView.scope.launch {
|
job = rootView.scope.launch {
|
||||||
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
rootView.lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
launch {
|
launch {
|
||||||
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
|
iconRepository.getIcon(searchable, (84 * rootView.dp).toInt())
|
||||||
.collectLatest {
|
.collectLatest {
|
||||||
|
|||||||
@ -37,7 +37,7 @@ open class InnerCardView @JvmOverloads constructor(
|
|||||||
super.onAttachedToWindow()
|
super.onAttachedToWindow()
|
||||||
job?.cancel()
|
job?.cancel()
|
||||||
job = lifecycleScope.launch {
|
job = lifecycleScope.launch {
|
||||||
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
dataStore.data.map { it.cards.radius }.distinctUntilChanged().collectLatest {
|
dataStore.data.map { it.cards.radius }.distinctUntilChanged().collectLatest {
|
||||||
radius = it * dp
|
radius = it * dp
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,7 +82,7 @@ open class LauncherCardView @JvmOverloads constructor(
|
|||||||
super.onAttachedToWindow()
|
super.onAttachedToWindow()
|
||||||
job?.cancel()
|
job?.cancel()
|
||||||
job = lifecycleScope.launch {
|
job = lifecycleScope.launch {
|
||||||
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
dataStore.data.map { it.cards }.distinctUntilChanged().collectLatest {
|
dataStore.data.map { it.cards }.distinctUntilChanged().collectLatest {
|
||||||
currentCardStyle = it
|
currentCardStyle = it
|
||||||
if (!overrideBackgroundOpacity) {
|
if (!overrideBackgroundOpacity) {
|
||||||
|
|||||||
@ -372,7 +372,7 @@ class SwipeCardView @JvmOverloads constructor(
|
|||||||
super.onAttachedToWindow()
|
super.onAttachedToWindow()
|
||||||
job?.cancel()
|
job?.cancel()
|
||||||
job = lifecycleScope.launch {
|
job = lifecycleScope.launch {
|
||||||
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
dataStore.data.map { it.cards.radius }.distinctUntilChanged().collectLatest {
|
dataStore.data.map { it.cards.radius }.distinctUntilChanged().collectLatest {
|
||||||
radius = it * dp
|
radius = it * dp
|
||||||
}
|
}
|
||||||
|
|||||||
@ -251,7 +251,7 @@ class FavoriteToolbarAction(val context: Context, val item: Searchable) : Toolba
|
|||||||
|
|
||||||
(context as LifecycleOwner).apply {
|
(context as LifecycleOwner).apply {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
repository.isPinned(item).collectLatest {
|
repository.isPinned(item).collectLatest {
|
||||||
isPinned = it
|
isPinned = it
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ class VisibilityToolbarAction(val context: Context, val item: Searchable) : Tool
|
|||||||
|
|
||||||
(context as LifecycleOwner).apply {
|
(context as LifecycleOwner).apply {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
repository.isHidden(item).collectLatest {
|
repository.isHidden(item).collectLatest {
|
||||||
isHidden = it
|
isHidden = it
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user