Markwon: Async drawable doesn't show up if it's the only thing in the text view

  • Markwon version: 4.2.1-SNAPSHOT + GlidePlugin

Async drawable doesn’t show up if it’s the only thing in the text view.

In the source code of the ReplacementSpan there’s this suspicious javadoc

   /**
     * Returns the width of the span. Extending classes can set the height of the span by updating
     * attributes of {@link android.graphics.Paint.FontMetricsInt}. If the span covers the whole
     * text, and the height is not set,
     * {@link #draw(Canvas, CharSequence, int, int, float, int, int, int, Paint)} will not be
     * called for the span.
     */
     public abstract int getSize(...)

And AsyncDrawable.initWithKnownDimensions(...) is only called if AsyncDrawableSpan.draw(...) of the parent span was called.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

I can reproduce it, the fix is going to be in the next 4.3.0 version (and upcoming snapshot). The problem is that Glide is setting placeholder as a regular result. AsyncDrawable receives the result, but as there are no canvas dimensions are available - there are no bounds available, thus span returns 0 for the size. Please note that this is the case when there is exactly one image span in the markdown. If there is at least one other character/span, result would be as OK

This is on API 29, on the emulator