Fix async-drawable tests

This commit is contained in:
Dimitry Ivanov 2019-06-21 00:56:43 +03:00
parent d630039196
commit 4fec46fb4d
2 changed files with 10 additions and 4 deletions

View File

@ -32,10 +32,11 @@ final Markwon markwon = Markwon.builder(context)
@Override
public void configureBuilder(@NonNull Builder builder) {
builder
.background(backgroundDrawable)
.align(JLatexMathDrawable.ALIGN_CENTER)
.fitCanvas(true)
.padding(paddingPx)
// @since 4.0.0 - change to provider
.backgroundProvider(() -> new MyDrawable()))
// @since 4.0.0 - optional, by default cached-thread-pool will be used
.executorService(Executors.newCachedThreadPool());
}

View File

@ -1,5 +1,6 @@
package io.noties.markwon.image;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Handler;
@ -144,9 +145,13 @@ class AsyncDrawableLoaderImpl extends AsyncDrawableLoader {
final Drawable out = drawable;
// @since 4.0.0-SNAPSHOT apply intrinsic bounds (but only if they are empty)
if (out != null
&& out.getBounds().isEmpty()) {
DrawableUtils.applyIntrinsicBounds(out);
if (out != null) {
final Rect bounds = out.getBounds();
//noinspection ConstantConditions
if (bounds == null
|| bounds.isEmpty()) {
DrawableUtils.applyIntrinsicBounds(out);
}
}
handler.postAtTime(new Runnable() {