Skip to content

Commit

Permalink
Fix removeSpan crash on Android (#469)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomek Zawadzki <[email protected]>
  • Loading branch information
wildan-m and tomekzaw authored Sep 12, 2024
1 parent 286eab7 commit d84f762
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
public class MarkdownTextWatcher implements TextWatcher {
private final MarkdownUtils mMarkdownUtils;

private boolean mShouldSkip = false;

public MarkdownTextWatcher(@NonNull MarkdownUtils markdownUtils) {
mMarkdownUtils = markdownUtils;
}
Expand All @@ -22,17 +20,13 @@ public void beforeTextChanged(CharSequence s, int start, int count, int after) {

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (mShouldSkip) {
return;
}
if (s instanceof SpannableStringBuilder) {
mMarkdownUtils.applyMarkdownFormatting((SpannableStringBuilder) s);
mShouldSkip = true;
}

}

@Override
public void afterTextChanged(Editable editable) {
mShouldSkip = false;
if (editable instanceof SpannableStringBuilder) {
mMarkdownUtils.applyMarkdownFormatting((SpannableStringBuilder) editable);
}
}
}

0 comments on commit d84f762

Please sign in to comment.