Skip to content

Commit

Permalink
Tweaked handling of null drawable.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbutcher authored and florina-muntenescu committed May 21, 2019
1 parent 7ddf18a commit 11d4ab9
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ class DarkenImage(context: Context, attrs: AttributeSet) : Transition(context, a
if (!isDarkTheme) return null
if (initialRgbScale == finalRgbScale) return null
val iv = endValues?.view as? ImageView ?: return null
if (iv.drawable == null) return null
val drawable = iv.drawable ?: return null
return ValueAnimator.ofFloat(initialRgbScale, finalRgbScale).apply {
addUpdateListener { listener ->
val cm = ColorMatrix()
val rgbScale = listener.animatedValue as Float
cm.setScale(rgbScale, rgbScale, rgbScale, ALPHA_SCALE)
iv.drawable.colorFilter = ColorMatrixColorFilter(cm)
drawable.colorFilter = ColorMatrixColorFilter(cm)
}
}
}
Expand Down

0 comments on commit 11d4ab9

Please sign in to comment.