Skip to content

Commit 48e6fbb

Browse files
authored
Fix crash in B&B onboarding (#6643)
Task/Issue URL: https://app.asana.com/1/137249556945/project/488551667048375/task/1211110430812532?focus=true ### Description ### Steps to test this PR - [x] Ensure you're launching into B&B onboarding, for example by editing RealOnboardingDesignExperimentManager.setCachedProperties() - [x] Set the phone in landscape orientation - [x] Launch the app - [x] Verify B&B pre onboarding doesn't crash ### No UI changes
1 parent e45fbea commit 48e6fbb

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

app/src/main/java/com/duckduckgo/app/onboarding/ui/page/BbWelcomePage.kt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ import com.duckduckgo.common.utils.extensions.preventWidows
7070
import com.duckduckgo.di.scopes.FragmentScope
7171
import javax.inject.Inject
7272
import kotlin.time.Duration.Companion.milliseconds
73+
import kotlinx.coroutines.delay
7374
import kotlinx.coroutines.flow.launchIn
7475
import kotlinx.coroutines.flow.onEach
76+
import kotlinx.coroutines.launch
7577

7678
@InjectWith(FragmentScope::class)
7779
class BbWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welcome_page_bb) {
@@ -91,7 +93,8 @@ class BbWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welcome
9193
}
9294

9395
private var welcomeAnimation: ViewPropertyAnimatorCompat? = null
94-
private var welcomeTitleAnimator: ViewPropertyAnimator? = null
96+
private var welcomeTitleEntryAnimator: ViewPropertyAnimator? = null
97+
private var welcomeTitleExitAnimator: ViewPropertyAnimator? = null
9598
private var daxDialogAnimator: ValueAnimator? = null
9699
private var daxDialogAnimationStarted = false
97100
private var backgroundSceneManager: BbOnboardingBackgroundSceneManager? = null
@@ -176,7 +179,8 @@ class BbWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welcome
176179
override fun onDestroyView() {
177180
super.onDestroyView()
178181
welcomeAnimation?.cancel()
179-
welcomeTitleAnimator?.cancel()
182+
welcomeTitleEntryAnimator?.cancel()
183+
welcomeTitleExitAnimator?.cancel()
180184
daxDialogAnimator?.cancel()
181185
}
182186

@@ -445,13 +449,14 @@ class BbWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welcome
445449
}
446450

447451
private fun startWelcomeAnimation() {
448-
binding.daxLogo.postDelayed(400) {
452+
viewLifecycleOwner.lifecycleScope.launch {
453+
delay(400.milliseconds)
449454
binding.daxLogo.setMaxFrame(13)
450455
binding.daxLogo.playAnimation()
451456
}
452457

453458
binding.welcomeTitle.translationY = 32f.toPx()
454-
binding.welcomeTitle.animate()
459+
welcomeTitleEntryAnimator = binding.welcomeTitle.animate()
455460
.alpha(MAX_ALPHA)
456461
.translationY(0f)
457462
.setDuration(800)
@@ -472,7 +477,8 @@ class BbWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welcome
472477
val transitionDelay = 1300.milliseconds
473478
val transitionDuration = SCENE_TRANSITION_DURATION
474479

475-
binding.daxLogo.postDelayed(winkDelay.inWholeMilliseconds) {
480+
viewLifecycleOwner.lifecycleScope.launch {
481+
delay(winkDelay)
476482
binding.daxLogo.setMaxFrame(42)
477483
binding.daxLogo.resumeAnimation()
478484
}
@@ -538,7 +544,7 @@ class BbWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welcome
538544
it.start()
539545
}
540546

541-
welcomeTitleAnimator = binding.welcomeTitle.animate()
547+
welcomeTitleExitAnimator = binding.welcomeTitle.animate()
542548
.translationX(-resources.displayMetrics.widthPixels.toFloat())
543549
.setDuration(transitionDuration.inWholeMilliseconds)
544550
.setStartDelay(transitionDelay.inWholeMilliseconds)

0 commit comments

Comments
 (0)