Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix removeSpan crash on Android #469

Merged
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);
}
}
}
Loading