Library - SocialView
Sweta Jain
Mobile Engineer - II at Expedia Group | Android | Kotlin | JetPack Compose | GraphQL | KMM
Do you know about SocialView?
SocialView is a library that is used to implement @mention, #hashtag and hyperlink in a single editText & textView.
WHY USE IT?
1. It shows #hashtag & @mention suggestion as you type.
2. You can use its by-default views for #hashtag & @mention & also you can use your own views.
3. You can also click any @mention, #hashtag & hyperlink and do any respective operation.
HOW TO USE IT?
1. implement socialView SDK dependency in the module "build.gradle" file.
2. social_view_version =" 0.3-rcl"
3. implementation "com.hendraanggrian.aapcompat:socialview-common:$social_view_version"
For enable @mention, #hashtag & hyperlink:
socialEditText.isMentionEnabled = true
socialEditText.isHashtagEnabled = true
socialEditText.isHyperlinkEnabled = true
Set text color of @mention, #hashtag & hyperlink:
socialTextView.mentionColor = ContextCompat.getColor(this, R.color.purple_700)
socialTextView.hashtagColor = ContextCompat.getColor(this, R.color.purple_700)
socialTextView.hyperlinkColor = ContextCompat.getColor(this, R.color.purple_700)
For @mention
socialEditText.setMentionTextChangedListener(object : SocialView.OnChangedListener{
override fun onChanged(view: SocialView, text: charSequence){
/**
*here you can request @mention api
*/
mentionApiRequest(text.toString())}})
For #hashtag
socialEditText.setHashtagTextChangedListener(object : SocialView.OnChangedListener{
override fun onChanged(view: SocialView, text: charSequence){
/**
*here you can request #hashtag api
*/
hashtagApiRequest(text.toString()) }})
Set clickListener of @mention, #hashtag & hyperlink
1) For @mention
socialTextView.setOnMentionClickListener(object: SocialView.OnClickListener{
override fun onClick(view: SocialView, text: CharSequence){
showMsg(“Mention -” +text.toString())}})
2) For #hashTag
socialTextView.setOnHashtagClickListener(object: SocialView.OnClickListener{
override fun onClick(view: SocialView, text: CharSequence){
showMsg(“Hashtag -” +text.toString())}})
3) For hyperlink
socialTextView.setOnHyperlinkClickListener(object: SocialView.OnClickListener{
override fun onClick(view: SocialView, text: CharSequence){
openLink(text.toString())}})
#SocialView #androiddevelopment #kotlin #developyourself
#developerlife #21dayschallenge
Hope you guys like it :)