Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kyawhtut-cu/6528a593269469399d279b3e586927be to your computer and use it in GitHub Desktop.
Save kyawhtut-cu/6528a593269469399d279b3e586927be to your computer and use it in GitHub Desktop.
//create global variable
private List<String> mTagList = new ArrayList<>();
//add tags change listener to TagsEdittext
mItemTags.setTagsListener(new TagsEditText.TagsEditListener() {
@Override
public void onTagsChanged(Collection<String> collection) {
Timber.i("onTagsChanged : %s", collection);
if (mTagList.size() != mItemTags.getTags().size()) {
boolean isDataChange = false;
mTagList.clear();
for (int index = 0; index < mItemTags.getTags().size(); index++) {
if (!mTagList.contains(mItemTags.getTags().get(index))) {
isDataChange = true;
mTagList.add(mItemTags.getTags().get(index));
}
}
if (isDataChange) {
String[] tmp = new String[mTagList.size()];
for (int index = 0; index < tmp.length; index++) {
tmp[index] = mTagList.get(index);
}
mItemTags.setTags(tmp);
}
}
}
@Override
public void onEditingFinished() {
Timber.i("onEditingFinished");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment