Last active
July 8, 2020 07:21
-
-
Save macieknajbar/da7699f2525097613ca0d61bd1052bd9 to your computer and use it in GitHub Desktop.
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
class ClickDrawable(layers: Array<out Drawable> = arrayOf()) : LayerDrawable(layers) { | |
… | |
private val mask: Drawable = | |
ColorDrawable(0xFF00FFFF.toInt()).apply { alpha = 0 } | |
init { | |
addLayer(mask) | |
} | |
… | |
@Keep | |
private fun setMaskAlpha(alpha: Int) { | |
mask.alpha = alpha | |
invalidateSelf() | |
} | |
private fun colorMask(fromAlpha: Int, toAlpha: Int) { | |
val anim = ObjectAnimator.ofInt(this, "maskAlpha", fromAlpha, toAlpha, fromAlpha) | |
anim.duration = DURATION | |
anim.interpolator = LinearInterpolator() | |
anim.start() | |
} | |
private fun setClickActive(active: Boolean) { | |
if (mActive != active) { | |
mActive = active | |
if (active && canStart) { | |
… | |
colorMask(0, 64) | |
} | |
} | |
} | |
@Keep | |
private fun setBounds(value: Float) { … } | |
… | |
private companion object { | |
const val DURATION = 225L | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment