Skip to content

Commit df476b5

Browse files
authored
Fix typing animation crash in B&B / Buck onboarding (#6672)
Task/Issue URL: https://app.asana.com/1/137249556945/project/488551667048375/task/1211147346596759?focus=true ### Description This PR prevents typing animations in pre-browser onboarding from being started after the view is destroyed. ### Steps to test this PR - [x] Smoke test B&B / Buck pre-browser onboarding. ### No UI changes
1 parent aefe870 commit df476b5

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,10 +587,10 @@ class BbWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welcome
587587
}
588588

589589
private fun scheduleTypingAnimation(textView: TypeAnimationTextView, text: String, afterAnimation: () -> Unit = {}) {
590-
textView.postDelayed(
591-
{ textView.startTypingAnimation(text, afterAnimation = afterAnimation) },
592-
ANIMATION_DURATION,
593-
)
590+
viewLifecycleOwner.lifecycleScope.launch {
591+
delay(ANIMATION_DURATION)
592+
textView.startTypingAnimation(text, afterAnimation = afterAnimation)
593+
}
594594
}
595595

596596
private fun showDefaultBrowserDialog(intent: Intent) {

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ import com.duckduckgo.common.utils.extensions.html
7373
import com.duckduckgo.common.utils.extensions.preventWidows
7474
import com.duckduckgo.di.scopes.FragmentScope
7575
import javax.inject.Inject
76+
import kotlinx.coroutines.delay
7677
import kotlinx.coroutines.flow.launchIn
7778
import kotlinx.coroutines.flow.onEach
79+
import kotlinx.coroutines.launch
7880

7981
@InjectWith(FragmentScope::class)
8082
class BuckWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welcome_page_buck) {
@@ -458,10 +460,10 @@ class BuckWelcomePage : OnboardingPageFragment(R.layout.content_onboarding_welco
458460
}
459461

460462
private fun scheduleTypingAnimation(textView: TypeAnimationTextView, text: String, afterAnimation: () -> Unit = {}) {
461-
textView.postDelayed(
462-
{ textView.startTypingAnimation(text, afterAnimation = afterAnimation) },
463-
ANIMATION_DURATION,
464-
)
463+
viewLifecycleOwner.lifecycleScope.launch {
464+
delay(ANIMATION_DURATION)
465+
textView.startTypingAnimation(text, afterAnimation = afterAnimation)
466+
}
465467
}
466468

467469
private fun showDefaultBrowserDialog(intent: Intent) {

0 commit comments

Comments
 (0)