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 @Override
public void configureBuilder(@NonNull Builder builder) { public void configureBuilder(@NonNull Builder builder) {
builder builder
.background(backgroundDrawable)
.align(JLatexMathDrawable.ALIGN_CENTER) .align(JLatexMathDrawable.ALIGN_CENTER)
.fitCanvas(true) .fitCanvas(true)
.padding(paddingPx) .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 // @since 4.0.0 - optional, by default cached-thread-pool will be used
.executorService(Executors.newCachedThreadPool()); .executorService(Executors.newCachedThreadPool());
} }

View File

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