Skip to content

Commit

Permalink
raise an exception if a drawable without intrinsic dimensions is used (
Browse files Browse the repository at this point in the history
  • Loading branch information
markusressel authored Jun 12, 2020
1 parent 1ec0e3a commit c906c5b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/src/main/java/com/otaliastudios/zoom/ZoomImageView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ open class ZoomImageView private constructor(

override fun setImageDrawable(drawable: Drawable?) {
if (drawable != null) {
if (drawable.intrinsicWidth == -1 || drawable.intrinsicHeight == -1) {
throw IllegalArgumentException("Drawables without intrinsic dimensions (such as a solid color) are not supported")
}
engine.setContentSize(drawable.intrinsicWidth.toFloat(),
drawable.intrinsicHeight.toFloat())
}
Expand Down

0 comments on commit c906c5b

Please sign in to comment.