hanggrian / socialview

Android TextView and EditText with hashtag, mention, and hyperlink support
http://hanggrian.com/socialview/
Apache License 2.0
323 stars 81 forks source link

Mention not show suggestions #63

Closed vsoftphuong closed 12 months ago

vsoftphuong commented 5 years ago

In class SocialAutoCompleteTextView in line 42, event onTextChanged it have error, you should use my code, my code is working well.

if (!TextUtils.isEmpty(s) && start < s.length()) { switch (s.charAt(start)) { case '#': if (getAdapter() != hashtagAdapter) { setAdapter(hashtagAdapter); } break; case '@': if (getAdapter() != mentionAdapter) { setAdapter(mentionAdapter); } break; } }

==> My solution:

if (!TextUtils.isEmpty(s) && s.length()>=2) { String string = s.toString(); String[] words = string.split(" "); if (words.length > 0) { String lastWord = words[words.length - 1]; //#h, @t if(lastWord.length()>=2){ if (lastWord.charAt(0) == '#') { String keyword = lastWord.substring(1); if (getAdapter() != hashtagAdapter) { setAdapter(hashtagAdapter); } } else if (lastWord.charAt(0) == '@') { String keyword = lastWord.substring(1); if (getAdapter() != mentionAdapter) { setAdapter(mentionAdapter); } } } } }

Hope to help improve your code! Thanks your project, it is very good!

hanggrian commented 4 years ago

I get a lot of issue reports for this library, but unfortunately not much for code suggestion. So thanks for your help.

I admit that the text watcher logic could be better, it's even reported in #7.

What would be great is that you could create a pull request submitting your code, also run all tests before submission.

Otherwise it might take me a while to apply your fixes, in the meantime I'm keeping this open.

hanggrian commented 12 months ago

Closed for inactivity.