Skip to content

Instantly share code, notes, and snippets.

View fornewid's full-sized avatar
🤖
on android

Sungyong An fornewid

🤖
on android
View GitHub Profile
class BlurViewModel : ViewModel() {
...
internal fun applyBlur(blurLevel: Int) {
val chargingConstraints = Constraints.Builder()
.setRequiresCharging(true)
.build()
val cleanupRequest = OneTimeWorkRequest
@fornewid
fornewid / ViewSpringAnimation.kt
Created July 7, 2019 14:09
View.spring() in #io19 motional intelligence session
fun animateVisibility(view: View, visible: Boolean) {
val targetAlpha = if (visible) 1f else 0f
if (view.alpha == targetAlpha) return
view.visibility = View.VISIBLE
val spring = view.spring(SpringAnimation.ALPHA)
(view.getTag(R.id.tag_pending_end_listener) as? DynamicAnimation.OnAnimationEndListener)?.let {
spring.removeEndListener(it)
}