@@ -70,8 +70,10 @@ import com.duckduckgo.common.utils.extensions.preventWidows
70
70
import com.duckduckgo.di.scopes.FragmentScope
71
71
import javax.inject.Inject
72
72
import kotlin.time.Duration.Companion.milliseconds
73
+ import kotlinx.coroutines.delay
73
74
import kotlinx.coroutines.flow.launchIn
74
75
import kotlinx.coroutines.flow.onEach
76
+ import kotlinx.coroutines.launch
75
77
76
78
@InjectWith(FragmentScope ::class )
77
79
class BbWelcomePage : OnboardingPageFragment (R .layout.content_onboarding_welcome_page_bb) {
@@ -91,7 +93,8 @@ class BbWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welcome
91
93
}
92
94
93
95
private var welcomeAnimation: ViewPropertyAnimatorCompat ? = null
94
- private var welcomeTitleAnimator: ViewPropertyAnimator ? = null
96
+ private var welcomeTitleEntryAnimator: ViewPropertyAnimator ? = null
97
+ private var welcomeTitleExitAnimator: ViewPropertyAnimator ? = null
95
98
private var daxDialogAnimator: ValueAnimator ? = null
96
99
private var daxDialogAnimationStarted = false
97
100
private var backgroundSceneManager: BbOnboardingBackgroundSceneManager ? = null
@@ -176,7 +179,8 @@ class BbWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welcome
176
179
override fun onDestroyView () {
177
180
super .onDestroyView()
178
181
welcomeAnimation?.cancel()
179
- welcomeTitleAnimator?.cancel()
182
+ welcomeTitleEntryAnimator?.cancel()
183
+ welcomeTitleExitAnimator?.cancel()
180
184
daxDialogAnimator?.cancel()
181
185
}
182
186
@@ -445,13 +449,14 @@ class BbWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welcome
445
449
}
446
450
447
451
private fun startWelcomeAnimation () {
448
- binding.daxLogo.postDelayed(400 ) {
452
+ viewLifecycleOwner.lifecycleScope.launch {
453
+ delay(400 .milliseconds)
449
454
binding.daxLogo.setMaxFrame(13 )
450
455
binding.daxLogo.playAnimation()
451
456
}
452
457
453
458
binding.welcomeTitle.translationY = 32f .toPx()
454
- binding.welcomeTitle.animate()
459
+ welcomeTitleEntryAnimator = binding.welcomeTitle.animate()
455
460
.alpha(MAX_ALPHA )
456
461
.translationY(0f )
457
462
.setDuration(800 )
@@ -472,7 +477,8 @@ class BbWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welcome
472
477
val transitionDelay = 1300 .milliseconds
473
478
val transitionDuration = SCENE_TRANSITION_DURATION
474
479
475
- binding.daxLogo.postDelayed(winkDelay.inWholeMilliseconds) {
480
+ viewLifecycleOwner.lifecycleScope.launch {
481
+ delay(winkDelay)
476
482
binding.daxLogo.setMaxFrame(42 )
477
483
binding.daxLogo.resumeAnimation()
478
484
}
@@ -538,7 +544,7 @@ class BbWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welcome
538
544
it.start()
539
545
}
540
546
541
- welcomeTitleAnimator = binding.welcomeTitle.animate()
547
+ welcomeTitleExitAnimator = binding.welcomeTitle.animate()
542
548
.translationX(- resources.displayMetrics.widthPixels.toFloat())
543
549
.setDuration(transitionDuration.inWholeMilliseconds)
544
550
.setStartDelay(transitionDelay.inWholeMilliseconds)
0 commit comments