Skip to content

Commit

Permalink
store mPreviousEditable as string to minimize conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
wildan-m committed Sep 11, 2024
1 parent c176a5e commit ade58bc
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class MarkdownTextWatcher implements TextWatcher {
private final MarkdownUtils mMarkdownUtils;
private boolean mShouldSkip = false;
private Editable mPreviousEditable;
private String mPreviousEditable;

public MarkdownTextWatcher(@NonNull MarkdownUtils markdownUtils) {
mMarkdownUtils = markdownUtils;
Expand All @@ -28,11 +28,12 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
@Override
public void afterTextChanged(Editable editable) {
if (editable instanceof SpannableStringBuilder) {
if (mPreviousEditable != null && mPreviousEditable.toString().equals(editable.toString())) {
String currentEditable = editable.toString();
if (mPreviousEditable != null && mPreviousEditable.equals(currentEditable)) {
return;
}
mMarkdownUtils.applyMarkdownFormatting((SpannableStringBuilder) editable);
mPreviousEditable = new SpannableStringBuilder(editable);
mPreviousEditable = currentEditable;
}
}
}

0 comments on commit ade58bc

Please sign in to comment.