linkedin / Spyglass

A library for mentions on Android
Apache License 2.0
387 stars 128 forks source link

Problem replacing the mentionText when sending to server #104

Open ritesh-karmare opened 4 years ago

ritesh-karmare commented 4 years ago

@nhibner Thanks for the amazing library.

However, I am facing the issue that replacing the mentioned text with userId is not working correctly. Referred to this issue #28, but no luck. Here's my code:

int startIndex = 0 
int sndIndex = 14 
String mentionedText = Ritesh Karmare
String tobeReplaceWith = "@[userId:"+8a968170720822e601720842ab98000b+"]";

userMessageEditText.getText().replace(start,end,tobeReplaceWith,0, tobeReplaceWith.length());
//userMessageEditText.getText().replace(start,end,tobeReplaceWith); // tried this as well.

output: Ritesh Karmare170720822e601720842ab98000b]

Expected Output: After selecting the mentioned text, the user should be able to view: (Working fine) Hello Ritesh Karmare

While sending to server, the message should be: (Not working) Hello @[userId:8a968170720822e601720842ab98000b]

Would appreciate your help in resolving this. Thank you in advance.

NischalManandhar commented 4 years ago

May be this helps: https://github.com/linkedin/Spyglass/issues/28#issuecomment-704930534