Created
January 18, 2020 12:49
-
-
Save krossovochkin/def897c0b75a62bad7f31210b4fc8a24 to your computer and use it in GitHub Desktop.
Theme_1
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
private fun setTheme(theme: ThemeManager.Theme, animate: Boolean = true) { | |
if (!animate) { | |
ThemeManager.theme = theme | |
return | |
} | |
if (imageView.isVisible) { | |
return | |
} | |
val w = container.measuredWidth | |
val h = container.measuredHeight | |
val bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888) | |
val canvas = Canvas(bitmap) | |
container.draw(canvas) | |
imageView.setImageBitmap(bitmap) | |
imageView.isVisible = true | |
val finalRadius = hypot(w.toFloat(), h.toFloat()) | |
ThemeManager.theme = theme | |
val anim = ViewAnimationUtils.createCircularReveal(imageView, w / 2, h / 2, finalRadius, 0f) | |
anim.duration = 400L | |
anim.doOnEnd { | |
imageView.setImageDrawable(null) | |
imageView.isVisible = false | |
} | |
anim.start() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment