Skip to content

Commit 713aa7a

Browse files
Cancel animations on rotation (#654)
1 parent ae426d0 commit 713aa7a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import android.view.View
2323
import android.view.WindowManager
2424
import androidx.core.content.ContextCompat
2525
import androidx.core.view.ViewCompat
26+
import androidx.core.view.ViewPropertyAnimatorCompat
2627
import com.duckduckgo.app.browser.R
2728
import com.duckduckgo.app.global.view.html
2829
import kotlinx.android.synthetic.main.include_dax_dialog_cta.*
@@ -33,6 +34,8 @@ import kotlinx.android.synthetic.main.content_onboarding_welcome.longDescription
3334
class WelcomePage : OnboardingPageFragment() {
3435

3536
private var ctaText: String = ""
37+
private var welcomeAnimation: ViewPropertyAnimatorCompat? = null
38+
private var typingAnimation: ViewPropertyAnimatorCompat? = null
3639

3740
override fun layoutResource(): Int = R.layout.content_onboarding_welcome
3841

@@ -50,6 +53,12 @@ class WelcomePage : OnboardingPageFragment() {
5053
applyFullScreenFlags()
5154
}
5255

56+
override fun onDestroy() {
57+
super.onDestroy()
58+
welcomeAnimation?.cancel()
59+
typingAnimation?.cancel()
60+
}
61+
5362
private fun applyFullScreenFlags() {
5463
activity?.window?.apply {
5564
clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
@@ -74,12 +83,12 @@ class WelcomePage : OnboardingPageFragment() {
7483
}
7584

7685
private fun beginWelcomeAnimation(ctaText: String) {
77-
ViewCompat.animate(welcomeContent as View)
86+
welcomeAnimation = ViewCompat.animate(welcomeContent as View)
7887
.alpha(MIN_ALPHA)
7988
.setDuration(ANIMATION_DURATION)
8089
.setStartDelay(ANIMATION_DELAY)
8190
.withEndAction {
82-
ViewCompat.animate(daxCtaContainer)
91+
typingAnimation = ViewCompat.animate(daxCtaContainer)
8392
.alpha(MAX_ALPHA)
8493
.setDuration(ANIMATION_DURATION)
8594
.withEndAction {

0 commit comments

Comments
 (0)