natario1 / ZoomLayout

2D zoom and pan behavior for View hierarchies, images, video streams, and much more, written in Kotlin for Android.
https://natario1.github.io/ZoomLayout
Apache License 2.0
1.05k stars 147 forks source link

Exception when setting null drawable #171

Open markusressel opened 4 years ago

markusressel commented 4 years ago

Describe the bug

Setting a null drawable strangely causes the Drawables without intrinsic dimensions (such as a solid color) are not supported exception to trigger. It seems like passing a null value to the setImageDrawable function actually results in setting a BitmapDrawable, see screenshot below.

To Reproduce

Steps to reproduce the behavior, possibly in the demo app:

  1. Open something using ZoomImageView
  2. use zoomImageView.setImageBitmap(null)
  3. See error

Expected behavior

Not sure, but I guess it should be possible to set a null image (simply show nothing at all).

Screenshots

image

Logs

    java.lang.IllegalArgumentException: Drawables without intrinsic dimensions (such as a solid color) are not supported
        at com.otaliastudios.zoom.ZoomImageView.setImageDrawable(ZoomImageView.kt:95)
        at android.widget.ImageView.setImageBitmap(ImageView.java:767)
        at de.markusressel.kodeeditor.library.view.CodeEditorLayout$updateMinimapImage$$inlined$apply$lambda$1.run(CodeEditorLayout.kt:409)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7682)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
chubecode commented 11 months ago

same here, I already try check null before using zoomImageView.setImageBitmap but the error still occur? anything else can help ?