Created
December 30, 2020 19:08
-
-
Save xAIdrian/d1ecba6b1c86810144bbc681ac674f73 to your computer and use it in GitHub Desktop.
Current Animation Assignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.amohnacs.currentapplication | |
import android.animation.* | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.view.View | |
import android.view.animation.AlphaAnimation | |
import android.view.animation.Animation | |
import android.view.animation.Animation.INFINITE | |
import androidx.core.animation.addListener | |
class AnimationActivity : AppCompatActivity() { | |
private lateinit var blackFadeView: View | |
private lateinit var purpleConstrictFadeOutView: View | |
private lateinit var gradientConstrictFadeInView: View | |
private lateinit var blackExpandView: View | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
blackFadeView = findViewById(R.id.black_background) | |
purpleConstrictFadeOutView = findViewById(R.id.purple_circle) | |
gradientConstrictFadeInView = findViewById(R.id.gradient_circle) | |
blackExpandView = findViewById(R.id.black_circle) | |
val gradientRotate = ObjectAnimator.ofFloat( | |
gradientConstrictFadeInView, | |
"rotation", | |
0f, | |
360f | |
).apply { | |
duration = 4000 | |
addListener ( object : AnimatorListenerAdapter() { | |
override fun onAnimationEnd(animation: Animator?) { | |
start() | |
} | |
}) | |
} | |
val fadoutBlack = ObjectAnimator.ofFloat( | |
blackFadeView, | |
"alpha", | |
1f, | |
0f | |
).apply { | |
duration = 1600 | |
} | |
val purpleConstrictX = ObjectAnimator.ofFloat( | |
purpleConstrictFadeOutView, | |
"scaleX", | |
1f, | |
0.15f | |
).apply { | |
duration = 4000 | |
} | |
val purpleConstrictY = ObjectAnimator.ofFloat( | |
purpleConstrictFadeOutView, | |
"scaleY", | |
1f, | |
0.1f | |
).apply { | |
duration = 4000 | |
} | |
val purpleFadOut = ObjectAnimator.ofFloat( | |
purpleConstrictFadeOutView, | |
"alpha", | |
1f, | |
0f | |
).apply { | |
duration = 1600 | |
} | |
val gradientConstrictX = ObjectAnimator.ofFloat( | |
gradientConstrictFadeInView, | |
"scaleX", | |
1f, | |
0.15f | |
).apply { | |
duration = 4000 | |
} | |
val gradientConstrictY = ObjectAnimator.ofFloat( | |
gradientConstrictFadeInView, | |
"scaleY", | |
1f, | |
0.1f | |
).apply { | |
duration = 4000 | |
} | |
val blackExpandX = ObjectAnimator.ofFloat( | |
blackExpandView, | |
"scaleX", | |
0f, | |
0.14f | |
).apply { | |
duration = 4000 | |
} | |
val blackExpandY = ObjectAnimator.ofFloat( | |
blackExpandView, | |
"scaleY", | |
0f, | |
0.09f | |
).apply { | |
duration = 4000 | |
addListener ( object : AnimatorListenerAdapter() { | |
override fun onAnimationEnd(animation: Animator?) { | |
gradientRotate.start() | |
} | |
}) | |
} | |
AnimatorSet().apply { | |
play(fadoutBlack) | |
.with(purpleConstrictX) | |
.with(purpleConstrictY) | |
.with(purpleFadOut) | |
.with(gradientConstrictX) | |
.with(gradientConstrictY) | |
.with(blackExpandX) | |
.with(blackExpandY) | |
start() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment