making use of the view lifecycle scope for the view based fragment logic

This commit is contained in:
Adam Brown 2022-05-05 11:06:16 +01:00
parent c0efd9f1af
commit 8136f57b5e
3 changed files with 3 additions and 3 deletions

View file

@ -68,7 +68,7 @@ class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractFt
views.chooseServerSubmit.debouncedClicks { updateServerUrl() } views.chooseServerSubmit.debouncedClicks { updateServerUrl() }
views.chooseServerInput.editText().textChanges() views.chooseServerInput.editText().textChanges()
.onEach { views.chooseServerInput.error = null } .onEach { views.chooseServerInput.error = null }
.launchIn(lifecycleScope) .launchIn(viewLifecycleOwner.lifecycleScope)
} }
private fun updateServerUrl() { private fun updateServerUrl() {

View file

@ -57,7 +57,7 @@ class FtueAuthEmailEntryFragment @Inject constructor() : AbstractFtueAuthFragmen
views.emailEntryInput.error = null views.emailEntryInput.error = null
views.emailEntrySubmit.isEnabled = it.isEmail() views.emailEntrySubmit.isEnabled = it.isEmail()
} }
.launchIn(lifecycleScope) .launchIn(viewLifecycleOwner.lifecycleScope)
} }
private fun updateEmail() { private fun updateEmail() {

View file

@ -109,7 +109,7 @@ class FtueAuthSplashCarouselFragment @Inject constructor(
private fun ViewPager2.scheduleCarouselTransition(): Job { private fun ViewPager2.scheduleCarouselTransition(): Job {
val itemCount = adapter?.itemCount ?: throw IllegalStateException("An adapter must be set") val itemCount = adapter?.itemCount ?: throw IllegalStateException("An adapter must be set")
return lifecycleScope.launch { return viewLifecycleOwner.lifecycleScope.launch {
delay(CAROUSEL_ROTATION_DELAY_MS) delay(CAROUSEL_ROTATION_DELAY_MS)
setCurrentItem(currentItem.incrementByOneAndWrap(max = itemCount - 1), duration = CAROUSEL_TRANSITION_TIME_MS) setCurrentItem(currentItem.incrementByOneAndWrap(max = itemCount - 1), duration = CAROUSEL_TRANSITION_TIME_MS)
} }