Last active
May 19, 2019 14:42
-
-
Save arunkumar9t2/5f1d045beb4b787cfd1a106782f59f0e to your computer and use it in GitHub Desktop.
This file contains 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
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