private boolean commitChip(final int start,final int end,final Editable editable)
{
final ListAdapter adapter=getAdapter();
if(adapter!=null&&adapter.getCount()>0&&enoughToFilter()&&end==getSelectionEnd()&&!isPhoneQuery())
{
// choose the first entry.
submitItemAtPosition(0);
dismissDropDown();
return true;
}
else
{
int tokenEnd=mTokenizer.findTokenEnd(editable,start);
if(editable.length()>tokenEnd+1)
{
final char charAt=editable.charAt(tokenEnd+1);
if(charAt==COMMIT_CHAR_COMMA||charAt==COMMIT_CHAR_SEMICOLON)
tokenEnd++;
}
final String text=editable.toString().substring(start,tokenEnd).trim();
clearComposingText();
if(text!=null&&text.length()>0&&!text.equals(" "))
{
final RecipientEntry entry=createTokenizedEntry(text);
if(entry!=null)
{
QwertyKeyListener.markAsReplaced(editable,start,end,"");
final 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;
}
RecipientEditTextView.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:ChipsLibrary
作者:
评论列表
文章目录