Update changelog

This commit is contained in:
Dimitry Ivanov 2020-03-31 23:41:10 +03:00
parent b48b0889da
commit 0ae3a3d66e
2 changed files with 13 additions and 8 deletions

View File

@ -5,10 +5,12 @@
* module `images`: `GifSupport` and `SvgSupport` use `Class.forName` instead access to full qualified class name
* `ext-table`: fix links in tables ([#224])
* `ext-table`: proper borders (equal for all sides)
* module `core`: Add `PrecomputedFutureTextSetterCompat`<br>Thanks [@KirkBushman]
[#216]: https://github.com/noties/Markwon/pull/216
[#224]: https://github.com/noties/Markwon/issues/224
[@francescocervone]: https://github.com/francescocervone
[@KirkBushman]: https://github.com/KirkBushman
# 4.3.0

View File

@ -1,7 +1,6 @@
package io.noties.markwon;
import android.text.Spanned;
import android.util.Log;
import android.widget.TextView;
import androidx.annotation.NonNull;
@ -10,12 +9,14 @@ import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.text.PrecomputedTextCompat;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
/**
* Please note this class requires `androidx.core:core` artifact being explicitly added to your dependencies.
* This is intended to be used in a RecyclerView.
*
* @see io.noties.markwon.Markwon.TextSetter
* @since $nap;
*/
public class PrecomputedFutureTextSetterCompat implements Markwon.TextSetter {
@ -47,16 +48,18 @@ public class PrecomputedFutureTextSetterCompat implements Markwon.TextSetter {
@NonNull Spanned markdown,
@NonNull TextView.BufferType bufferType,
@NonNull Runnable onComplete) {
if (textView instanceof AppCompatTextView) {
((AppCompatTextView) textView).setTextFuture(PrecomputedTextCompat.getTextFuture(
markdown, ((AppCompatTextView) textView).getTextMetricsParamsCompat(), executor
));
final AppCompatTextView appCompatTextView = (AppCompatTextView) textView;
final Future<PrecomputedTextCompat> future = PrecomputedTextCompat.getTextFuture(
markdown,
appCompatTextView.getTextMetricsParamsCompat(),
executor);
appCompatTextView.setTextFuture(future);
// `setTextFuture` is actually a synchronous call, so we should call onComplete now
onComplete.run();
} else {
throw new IllegalStateException("TextView provided is not a child of AppCompatTextView, cannot call setTextFuture().");
throw new IllegalStateException("TextView provided is not an instance of AppCompatTextView, " +
"cannot call setTextFuture(), textView: " + textView);
}
}
}