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()
|
||||
|
||||
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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user