/** * Helper method to apply parsed markdown with additional argument of a MovementMethod. Used * to workaround problems that occur when using system LinkMovementMethod (for example: * https://issuetracker.google.com/issues/37068143). As a better alternative to it consider * using: https://github.com/saket/Better-Link-Movement-Method * * @param view TextView to set markdown into * @param text parsed markdown * @param movementMethod an implementation if MovementMethod or null * @see #scheduleDrawables(TextView) * @see #scheduleTableRows(TextView) * @since 1.0.6 */ public static void setText(@NonNull TextView view, CharSequence text, @Nullable MovementMethod movementMethod) { unscheduleDrawables(view); unscheduleTableRows(view); // @since 2.0.1 we must measure ordered-list-item-spans before applying text to a TextView. // if markdown has a lot of ordered list items (or text size is relatively big, or block-margin // is relatively small) then this list won't be rendered properly: it will take correct // layout (width and margin) but will be clipped if margin is not _consistent_ between calls. OrderedListItemSpan.measure(view, text); // update movement method (for links to be clickable) view.setMovementMethod(movementMethod); view.setText(text); // schedule drawables (dynamic drawables that can change bounds/animate will be correctly updated) scheduleDrawables(view); scheduleTableRows(view); }