hanggrian / socialview

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

How to get custom object of All mentions ? like Person id and Person Name #17

Closed tusharuit25 closed 1 year ago

hanggrian commented 7 years ago

I'm sorry to tell you that this feature isn't implemented yet. Although it is not impossible to do so, there are few caveats to note:

  1. If implemented, this feature will only make sense in socialview-commons
  2. Getting these custom objects will ignore hashtags/mentions not selected from the adapter. (because they are explicitly written by users, not by suggestions)
  3. Not everyone might need this feature.

I'll keep this issue open for more input.

tusharuit25 commented 7 years ago

This feature is needed because programmer might need to send who are those which are mentioned while typing text and need to send some notifications to them explicitly that you are mentioned; at least need id.

hanggrian commented 7 years ago

I could run a few tests first to see how reliable this feature could be. How urgent do you need this feature?

tusharuit25 commented 7 years ago

I used your component it work like butter ; I would appreciate if you can just let me know how to get selected item (object) which we select it from autocomplete suggestions. I have 3 days time to complete this feature in my project.

hanggrian commented 7 years ago

Well that sounds very urgent (thanks for the compliment btw). I could write some functions right now before this feature is fully implemented. Are you writing the project in Java/Kotlin? If it is Java, do you have access to lamdba (Java 8)? Do you use RxJava by any chance?

tusharuit25 commented 7 years ago

Its JAVA at my end ; plane java

hanggrian commented 7 years ago

Change Mention to your custom object:

@NonNull
public Collection<Mention> getMentionObjects(@NonNull SocialAutoCompleteTextView textView) {
    Collection<Mention> objects = new ArrayList<>();
    ArrayAdapter<Mention> adapter = (ArrayAdapter<Mention>) textView.getMentionAdapter();
    for (String mention : textView.getMentions()) {
        for (int i = 0; i < adapter.getCount(); i++) {
            Mention object = adapter.getItem(i);
            if (mention.equals(object.getUsername())) {
                objects.add(object);
            }
        }
    }
    return objects;
}

It's not the best approach, use it only if you are that urgent.

tusharuit25 commented 7 years ago

Ok Thank you @HendraAnggrian

hanggrian commented 7 years ago

@tusharuit25 You're very much welcome. I'll update this thread for future progress of this feature, thank you for your suggestion!

MuhammadFarazAhmed commented 6 years ago

how to set listners to when mention is clicked i want to send id when user click on mention

AshaChaparala commented 6 years ago

I want to get mention id when User click on mention,I have tried a lot but no luck...... Can you please tell me how to achieve this ...

tusharuit25 commented 6 years ago

@hendraanggrian I strongly recommend that your Mention object should contain Id

AhmadIzaz commented 4 years ago

@MuhammadFarazAhmed did you find any way to get click listener when user click on item on list

AhmadIzaz commented 4 years ago

@hendraanggrian I want to know the click event when user click on the item of dropdown. Is there any way ??

hardikJoshi123 commented 3 years ago

Suppose I taged 10 users within post. How to get ID of clicked taged item? Suppose :

Hi [at]Hardik How are you? [at]Peter

Tapping on [at]Hardik I need to get his user ID and redirect to his profile.

Is this achievable with this library?

tusharkshirsagar2021 commented 3 years ago
@NonNull
public Collection<Mention> getMentionObjects(@NonNull SocialAutoCompleteTextView textView) {
    Collection<Mention> objects = new ArrayList<>();
    ArrayAdapter<Mention> adapter = (ArrayAdapter<Mention>) textView.getMentionAdapter();
    for (String mention : textView.getMentions()) {
        for (int i = 0; i < adapter.getCount(); i++) {
            Mention object = adapter.getItem(i);
            if (mention.equals(object.getUsername())) {
                objects.add(object);
            }
        }
    }
    return objects;
}
hardikJoshi123 commented 3 years ago

Screenshot 2021-07-27 at 12 44 19 PM

Hi Tushar. Thanks for your quick reply. Actually I am using SocialTextView to display post description in Recycleview. Now I am trying to grab user's ID whenever user tap on any tagged user in that post. I tried to use above method which you shared. But its giving me error. Would you please help? @tusharkshirsagar2021

hardikJoshi123 commented 3 years ago

I want to get mention id when User click on mention,I have tried a lot but no luck...... Can you please tell me how to achieve this ...

Any idea on this? @hendraanggrian

hanggrian commented 3 years ago

how to set listners to when mention is clicked i want to send id when user click on mention

You could do it with textView.setOnMentionClickListener.

hanggrian commented 3 years ago

@hendraanggrian I strongly recommend that your Mention object should contain Id

Mention is not mandatory, but the interface Mentionable is. The unique id is getUsername.

hanggrian commented 3 years ago

@hendraanggrian I want to know the click event when user click on the item of dropdown. Is there any way ??

This isn't a supported behavior by MultiAutoCompleteTextView, which is a direct superclass of SocialAutoCompleteTextView. I'm sorry.

hanggrian commented 3 years ago

Suppose I taged 10 users within post. How to get ID of clicked taged item? Suppose :

Hi [at]Hardik How are you? [at]Peter

Tapping on [at]Hardik I need to get his user ID and redirect to his profile.

Is this achievable with this library?

Now let us go through this scenario for a moment. The id (or in this case, Mentionable.getUsername) is only present when you are picking those mentions from dropdownlist with SocialAutoCompleteTextView. If by any chance you are manually typing those mentions, the library has no idea of knowing their ids.

I'm not saying that this feature is unachievable. It's just add a bulk of logic to what is supposed to be a simple library.

hanggrian commented 1 year ago

Closed for inactivity.