public interface AutocompletePolicy
AutocompletePresenter.for the simplest possible implementation| Modifier and Type | Method and Description |
|---|---|
java.lang.CharSequence |
getQuery(android.text.Spannable text)
Called to understand which query should be passed to
AutocompletePresenter
for a showing popup. |
void |
onDismiss(android.text.Spannable text)
Called when popup is dismissed.
|
boolean |
shouldDismissPopup(android.text.Spannable text,
int cursorPos)
Called to understand whether a currently shown popup should be closed, maybe
because text is invalid.
|
boolean |
shouldShowPopup(android.text.Spannable text,
int cursorPos)
Called to understand whether the popup should be shown.
|
boolean shouldShowPopup(android.text.Spannable text,
int cursorPos)
return text.length() > 0
- Show when last char is @: return text.getCharAt(text.length()-1) == '@'text - current text, along with its SpanscursorPos - the position of the cursorboolean shouldDismissPopup(android.text.Spannable text,
int cursorPos)
return !shouldShowPopup(text, cursorPos).
However this is defined so you can add or clear spans.text - current text, along with its SpanscursorPos - the position of the cursorjava.lang.CharSequence getQuery(android.text.Spannable text)
AutocompletePresenter
for a showing popup. If this is called, shouldShowPopup(Spannable, int) just returned
true, or shouldDismissPopup(Spannable, int) just returned false.
This is useful to understand which part of the text should be passed to presenters.
For example, user might have typed '@john' to select a username, but you just want to
search for 'john'.
For more complex cases, you can add inclusive Spans in shouldShowPopup(Spannable, int),
and get the span position here.text - current text, along with its Spansvoid onDismiss(android.text.Spannable text)
text - text at the moment of dismissing