Skip to content

Commit

Permalink
Make the confetti fit the screen and fade
Browse files Browse the repository at this point in the history
  • Loading branch information
Radiokot committed Nov 27, 2024
1 parent 585a7dd commit e1a96c5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31,681 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.concordium.wallet.ui.account.accountsoverview

import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams
import android.view.animation.AccelerateDecelerateInterpolator
import android.view.animation.AccelerateInterpolator
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
Expand All @@ -33,9 +38,9 @@ import com.concordium.wallet.ui.base.BaseFragment
import com.concordium.wallet.ui.cis2.SendTokenActivity
import com.concordium.wallet.ui.more.export.ExportActivity
import com.concordium.wallet.ui.more.notifications.NotificationsPermissionDialog
import com.concordium.wallet.ui.onboarding.OnboardingState
import com.concordium.wallet.ui.onboarding.OnboardingFragment
import com.concordium.wallet.ui.onboarding.OnboardingSharedViewModel
import com.concordium.wallet.ui.onboarding.OnboardingState
import com.concordium.wallet.ui.onramp.CcdOnrampSitesActivity
import com.concordium.wallet.util.KeyCreationVersion
import com.concordium.wallet.util.Log
Expand Down Expand Up @@ -71,7 +76,7 @@ class AccountsOverviewFragment : BaseFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
savedInstanceState: Bundle?,
): View {
binding = FragmentAccountsOverviewBinding.inflate(inflater, container, false)
onboardingBinding = FragmentOnboardingBinding.inflate(layoutInflater)
Expand Down Expand Up @@ -330,26 +335,33 @@ class AccountsOverviewFragment : BaseFragment() {
}

private fun initializeAnimation() {
binding.confettiAnimation.addAnimatorListener(object : Animator.AnimatorListener {
override fun onAnimationStart(p0: Animator) {}
val handler = Handler(Looper.getMainLooper())
binding.confettiAnimation.addAnimatorListener(object : AnimatorListenerAdapter() {
override fun onAnimationStart(p0: Animator) {
handler.postDelayed({
binding.confettiAnimation.animate()
.setInterpolator(AccelerateInterpolator())
.alpha(0f)
.scaleXBy(0.3f)
.scaleYBy(0.3f)
.setDuration(900)
.setListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
cancelAnimation()
}
})
}, 800)
}

override fun onAnimationEnd(p0: Animator) {
cancelAnimation()
}

override fun onAnimationCancel(p0: Animator) {}

override fun onAnimationRepeat(p0: Animator) {}

})

binding.confettiAnimation.addAnimatorPauseListener(object : Animator.AnimatorPauseListener {
binding.confettiAnimation.addAnimatorPauseListener(object : AnimatorListenerAdapter() {
override fun onAnimationPause(p0: Animator) {
cancelAnimation()
}

override fun onAnimationResume(p0: Animator) {}

})
}

Expand Down Expand Up @@ -504,4 +516,4 @@ class AccountsOverviewFragment : BaseFragment() {
}

//endregion
}
}
5 changes: 3 additions & 2 deletions app/src/main/res/layout/fragment_accounts_overview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
layout="@layout/list_item_accounts_overview_ccd_onramp_banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginHorizontal="@dimen/activity_vertical_margin" />
android:layout_marginHorizontal="@dimen/activity_vertical_margin"
android:layout_marginTop="32dp" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/account_recyclerview"
Expand Down Expand Up @@ -174,6 +174,7 @@
android:id="@+id/confetti_animation"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
Loading

0 comments on commit e1a96c5

Please sign in to comment.