Skip to content

Instantly share code, notes, and snippets.

@arunkumar9t2
Last active May 19, 2019 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arunkumar9t2/5f1d045beb4b787cfd1a106782f59f0e to your computer and use it in GitHub Desktop.
Save arunkumar9t2/5f1d045beb4b787cfd1a106782f59f0e to your computer and use it in GitHub Desktop.
val AppCompatActivity.hasSourceBounds: Boolean get() = intent?.sourceBounds != null
fun AppCompatActivity.sourceBounds(boundsAction: (Rect) -> Unit) {
intent?.sourceBounds?.let(boundsAction)
}
/**
* Disables upcoming transition when [hasSourceBounds] is true. Should be called before [AppCompatActivity.onCreate]
*/
fun AppCompatActivity.preAnimationSetup() {
if (hasSourceBounds) {
overridePendingTransition(0, 0)
}
}
/**
* @return [ValueAnimator] that animates status bar color from [TRANSPARENT] to current status bar color
*/
val AppCompatActivity.statusBarAnimator: Animator
get() = ValueAnimator.ofArgb(TRANSPARENT, window.statusBarColor)
.animatedValue(window::setStatusBarColor)
/**
* @return [ValueAnimator] that animates navigation bar color from [TRANSPARENT] to current navigation bar color
*/
val AppCompatActivity.navigationBarAnimator: Animator
get() = ValueAnimator.ofArgb(TRANSPARENT, window.navigationBarColor)
.animatedValue(window::setNavigationBarColor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment