private boolean commitChip(int start, int end, Editable editable) {
ListAdapter adapter = getAdapter();
if (adapter != null && adapter.getCount() > 0 && enoughToFilter()
&& end == getSelectionEnd()) {
// choose the first entry.
submitItemAtPosition(0);
dismissDropDown();
return true;
} else {
int tokenEnd = mTokenizer.findTokenEnd(editable, start);
if (editable.length() > tokenEnd + 1) {
char charAt = editable.charAt(tokenEnd + 1);
if (charAt == COMMIT_CHAR_COMMA || charAt == COMMIT_CHAR_SEMICOLON) {
tokenEnd++;
}
}
String text = editable.toString().substring(start, tokenEnd).trim();
clearComposingText();
if (text != null && text.length() > 0 && !text.equals(" ")) {
String entry = createTokenizedEntry(text);
if (entry != null) {
QwertyKeyListener.markAsReplaced(editable, start, end, "");
CharSequence chipText = createChip(entry, false);
if (chipText != null && start > -1 && end > -1) {
editable.replace(start, end, chipText);
}
}
// Only dismiss the dropdown if it is related to the text we
// just committed.
// For paste, it may not be as there are possibly multiple
// tokens being added.
if (end == getSelectionEnd()) {
dismissDropDown();
}
sanitizeBetween();
return true;
}
}
return false;
}
ChipEditTextView.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:android-chip-edittextview
作者:
评论列表
文章目录