Small improvement

pull/214/head
M66B 1 year ago
parent 35ff1fd41b
commit 6bda014ba4

@ -506,19 +506,24 @@ public class EditTextCompose extends FixedEditText {
if (selectionListener != null) if (selectionListener != null)
selectionListener.onSelected(hasSelection()); selectionListener.onSelected(hasSelection());
if (selStart != lastStart && selEnd != lastEnd) { int start = -1;
lastStart = selStart; int end = -1;
lastEnd = selEnd;
Editable edit = getText(); Editable edit = getText();
if (lastStart >= 0 && edit != null && lt_description) { if (lt_description && selStart >= 0 && edit != null) {
SuggestionSpanEx[] suggestions = getText().getSpans(selStart, selEnd, SuggestionSpanEx.class); SuggestionSpanEx[] suggestions = edit.getSpans(selStart, selEnd, SuggestionSpanEx.class);
if (suggestions != null && suggestions.length > 0) { if (suggestions != null && suggestions.length > 0) {
start = edit.getSpanStart(suggestions[0]);
end = edit.getSpanEnd(suggestions[0]);
if (start != lastStart && end != lastEnd) {
String description = suggestions[0].getDescription(); String description = suggestions[0].getDescription();
if (!TextUtils.isEmpty(description)) if (!TextUtils.isEmpty(description))
ToastEx.makeText(getContext(), description, Toast.LENGTH_LONG).show(); ToastEx.makeText(getContext(), description, Toast.LENGTH_LONG).show();
} }
} }
} }
lastStart = start;
lastEnd = end;
} }
@Override @Override

Loading…
Cancel
Save