mabbas007 / TagsEditText

Android EditText for view tags or chips
Apache License 2.0
694 stars 124 forks source link

How to prevent from adding tag that already exist? #30

Open IvanKnyaziev opened 7 years ago

IvanKnyaziev commented 7 years ago

How can I prevent from adding existing tag? Or if I have "John Smith" tag and I click to add this one again, how can I remove all "John Smith" tags?

IvanKnyaziev commented 7 years ago

I did it=)

sunnymopada commented 7 years ago

@IvanKnyaziev How did you do that?

ashishparmar commented 6 years ago

how can you achieve this ?

IvanKnyaziev commented 6 years ago

@ashishparmar write here you email, I will send you upgraded version

ashishparmar commented 6 years ago

ashish4072@gmail.com

ashishparmar commented 6 years ago

have you send ?

ashishparmar commented 6 years ago

@IvanKnyaziev : Still i can't achieve this functionality is there any solution?

IvanKnyaziev commented 6 years ago

You can't clear all the tags(chips) from view if you need?

2017-12-12 13:47 GMT+02:00 ashishparmar notifications@github.com:

@IvanKnyaziev https://github.com/ivanknyaziev : Still i can't achieve this functionality is there any solution?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mabbas007/TagsEditText/issues/30#issuecomment-351028563, or mute the thread https://github.com/notifications/unsubscribe-auth/AZCCOUsTIoO6b7a9GTYim9WI0nHZMEpaks5s_mfSgaJpZM4NJ-GK .

ghost commented 6 years ago

private String getNewTag(String newString) { StringBuilder builder = new StringBuilder(); for (Tag tag : mTags) { if (!tag.isSpan()) continue; builder.append(tag.getSource()).append(mSeparator); } String[] strItem= builder.toString().split(mSeparator); String[] newItem=newString.split(mSeparator); HashSet s1 = new HashSet(Arrays.asList(newItem)); s1.removeAll(Arrays.asList(strItem)); Iterator iterator = s1.iterator(); String strNewTag=""; if(iterator.hasNext()){ strNewTag= iterator.next().toString()+" "; } return strNewTag; }

kyawhtut-cu commented 5 years ago

How to prevent from adding tag that already exist?

https://gist.github.com/kyawhtut-cu/6528a593269469399d279b3e586927be