Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当我把@信息保存为草稿时,再次使用期@属性丢失。 #19

Closed
wang521314 opened this issue Aug 26, 2019 · 1 comment
Closed

Comments

@wang521314
Copy link

感谢您的开源,我在项目中使用了您的工程,现在我有个问题当我在聊天页面有@信息时,使用是正常,但是当我把@信息保存为草稿时,再次进入取出草稿里的@信息时,这时就是一个普通的字符串了,此时我应当怎么做。如果有时间请您回复下。谢谢!

@sunhapper
Copy link
Owner

看你的描述应该是保存草稿时只保存了TextView中字符串的信息,而样式这些信息没有保存。
思路大概两条
一种是把样式相关的信息在保存字符串时也保存下来,比如demo中的MentionUser中的name,注意这时需要获取数据在SpannableString中对应的start和end,也保存起来,在恢复的时候去重新创建新的样式的span
或者不保存上面的信息,但是你可以构建一套规则去匹配出字符串中特殊的样式,这个可以参照EmojiManager.getSpannableByPattern 不过不是很建议这么做,因为场景稍微复杂一点正则匹配就很难做到完全不出问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants