public interface ChipTokenizer
Tokenizer that provides extra support
for chipification.
In the context of this interface, a token is considered to be plain (non-chipped) text. Once a token is terminated it becomes or contains a chip.
The CharSequences passed to the ChipTokenizer methods may contain both chipped text
and plain text so the tokenizer must have some method of distinguishing between the two (e.g. using a delimeter character.
The terminateToken(CharSequence, Object) method is where a chip can be formed and returned to replace the plain text.
Whatever class the implementation deems to represent a chip, must implement the Chip interface.
SpanChipTokenizer| Modifier and Type | Method and Description |
|---|---|
void |
applyConfiguration(android.text.Editable text,
ChipConfiguration chipConfiguration)
Configures this ChipTokenizer to produce chips with the provided attributes.
|
void |
deleteChip(Chip chip,
android.text.Editable text)
Removes a chip and any text it encompasses from
text. |
void |
deleteChipAndPadding(Chip chip,
android.text.Editable text)
Removes a chip, any text it encompasses AND any padding text (such as spaces) that may have been inserted when the chip was created in
terminateToken(CharSequence, Object) or after. |
Chip[] |
findAllChips(int start,
int end,
android.text.Spanned text)
Searches through
text for any chips |
java.util.List<android.util.Pair<java.lang.Integer,java.lang.Integer>> |
findAllTokens(java.lang.CharSequence text)
Searches through
text for any tokens. |
int |
findChipEnd(Chip chip,
android.text.Spanned text)
Finds the index of the character after the last character in
text that is a part of chip |
int |
findChipStart(Chip chip,
android.text.Spanned text)
Finds the index of the first character in
text that is a part of chip |
int |
findTokenEnd(java.lang.CharSequence text,
int cursor)
Returns the end of the token (minus trailing punctuation)
that begins at offset
cursor within text. |
int |
findTokenStart(java.lang.CharSequence text,
int cursor)
Returns the start of the token that ends at offset
cursor within text. |
void |
revertChipToToken(Chip chip,
android.text.Editable text)
Effectively does the opposite of
terminateToken(CharSequence, Object) by reverting the provided chip back into a token. |
void |
terminateAllTokens(android.text.Editable text)
Terminates (converts from token into chip) all unterminated tokens in the provided text.
|
java.lang.CharSequence |
terminateToken(java.lang.CharSequence text,
java.lang.Object data)
Returns
text, modified, if necessary, to ensure that
it ends with a token terminator (for example a space or comma). |
void applyConfiguration(android.text.Editable text,
ChipConfiguration chipConfiguration)
-1 or null may be
passed to indicate that the attribute may be ignored.
This will also apply the provided ChipConfiguration to any existing chips in the provided text.
text - the text in which to search for existing chips to apply the configuration tochipConfiguration - a ChipConfiguration containing customizations for the chips produced by this classint findTokenStart(java.lang.CharSequence text,
int cursor)
cursor within text.int findTokenEnd(java.lang.CharSequence text,
int cursor)
cursor within text.java.util.List<android.util.Pair<java.lang.Integer,java.lang.Integer>> findAllTokens(java.lang.CharSequence text)
text for any tokens.text - the text in which to search for un-terminated tokensPairs of the form (startIndex, endIndex) containing the locations of all
unterminated tokensjava.lang.CharSequence terminateToken(java.lang.CharSequence text,
java.lang.Object data)
text, modified, if necessary, to ensure that
it ends with a token terminator (for example a space or comma).void terminateAllTokens(android.text.Editable text)
text - the text in which to terminate all tokensint findChipStart(Chip chip, android.text.Spanned text)
text that is a part of chipchip - the chip whose start should be foundtext - the text in which to search for the start of chipint findChipEnd(Chip chip, android.text.Spanned text)
text that is a part of chipchip - the chip whose end should be foundtext - the text in which to search for the end of chipChip[] findAllChips(int start, int end, android.text.Spanned text)
text for any chipsstart - index to start looking for terminated tokens (inclusive)end - index to end looking for terminated tokens (exclusive)text - the text in which to search for terminated tokensChip interface to represent the terminated tokensvoid revertChipToToken(Chip chip, android.text.Editable text)
terminateToken(CharSequence, Object) by reverting the provided chip back into a token.
This method CAN alter the provided text.chip - the chip to revert into a tokentext - the text in which the chip residesvoid deleteChip(Chip chip, android.text.Editable text)
text. This method CAN alter the provided text.chip - the chip to removetext - the text to remove the chip fromvoid deleteChipAndPadding(Chip chip, android.text.Editable text)
terminateToken(CharSequence, Object) or after. This method CAN alter the provided text.chip - the chip to removetext - the text to remove the chip and padding from