From c906c5bae82cefcaca77d2417713303f10663cef Mon Sep 17 00:00:00 2001 From: Markus Ressel Date: Fri, 12 Jun 2020 17:26:51 +0200 Subject: [PATCH] raise an exception if a drawable without intrinsic dimensions is used (#157) --- library/src/main/java/com/otaliastudios/zoom/ZoomImageView.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/src/main/java/com/otaliastudios/zoom/ZoomImageView.kt b/library/src/main/java/com/otaliastudios/zoom/ZoomImageView.kt index 49dcc8e..adf7151 100644 --- a/library/src/main/java/com/otaliastudios/zoom/ZoomImageView.kt +++ b/library/src/main/java/com/otaliastudios/zoom/ZoomImageView.kt @@ -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()) }