1- <!DOCTYPE html>
1+ <!doctype html>
2+ < html lang ="en-us ">
3+ < head >
4+ < META http-equiv ="Content-Type " content ="text/html; charset=UTF-8 ">
5+ < meta charset ="utf-8 ">
6+ < title > socialview</ title >
7+ < meta content ="width=device-width, initial-scale=1 " name ="viewport ">
8+ < meta content ="#159957 " name ="theme-color ">
9+ < link href ="styles/main.css " rel ="stylesheet ">
10+ < link href ="styles/dark.css " rel ="stylesheet ">
11+ < link href ="styles/normalize.css " rel ="stylesheet ">
12+ < link href ="https://fonts.googleapis.com/css?family=Open+Sans:400,700 " rel ="stylesheet ">
13+ < link href ="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css " rel ="stylesheet ">
14+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js "> </ script > < script src ="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-groovy.min.js "> </ script >
15+ <!--Primary meta tags-->
16+ < meta content ="socialview " name ="title ">
17+ < meta content ="Android TextView and EditText with hashtag, mention, and hyperlink support " name ="description ">
18+ </ head >
19+ < body >
20+ < section class ="page-header ">
21+ < h1 class ="project-name "> socialview</ h1 >
22+ < h2 class ="project-tagline "> Android TextView and EditText with hashtag, mention, and hyperlink support</ h2 >
23+ </ section >
24+ < section class ="main-content ">
25+ < p >
26+ < a href ="https://travis-ci.com/github/hendraanggrian/socialview/ "> < img alt ="Travis CI " src ="https://img.shields.io/travis/com/hendraanggrian/socialview "> </ a >
27+ < a href ="https://codecov.io/gh/hendraanggrian/socialview/ "> < img alt ="Codecov " src ="https://img.shields.io/codecov/c/github/hendraanggrian/socialview "> </ a >
28+ < a href ="https://search.maven.org/artifact/com.hendraanggrian.appcompat/socialview/ "> < img alt ="Maven Central " src ="https://img.shields.io/maven-central/v/com.hendraanggrian.appcompat/socialview "> </ a >
29+ < a href ="https://s01.oss.sonatype.org/content/repositories/snapshots/com/hendraanggrian/appcompat/socialview/ "> < img alt ="Nexus Snapshot " src ="https://img.shields.io/nexus/s/com.hendraanggrian.appcompat/socialview?server=https%3A%2F%2Fs01.oss.sonatype.org "> </ a >
30+ < a href ="https://developer.android.com/studio/releases/platforms/#4.0 "> < img alt ="Android SDK " src ="https://img.shields.io/badge/sdk-14%2B-informational "> </ a >
31+ </ p >
32+
33+ < h1 > SocialView</ h1 >
34+
35+ < p >
36+ < img alt ="Hashtag preview. " src ="https://github.com/hendraanggrian/socialview/raw/assets/preview_hashtag.png ">
37+ < img alt ="Mention preview. " src ="https://github.com/hendraanggrian/socialview/raw/assets/preview_mention.png ">
38+ </ p >
39+
40+ < p > TextView and EditText with hashtag, mention, and hyperlink support.</ p >
41+
42+ < ul >
43+
44+ < li > Pre-loaded with default views, but also installable to any custom view.</ li >
45+
46+ < li > Display hashtag and mention suggestions as you type.</ li >
47+
48+ </ ul >
49+
50+ < h2 > Download</ h2 >
51+
52+ < pre > < code class ="language-gradle "> repositories {
53+ mavenCentral()
54+ google()
55+ }
56+ dependencies {
57+ // base widgets
58+ implementation "com.hendraanggrian.appcompat:socialview:$version"
259
3- < HTML >
4- < HEAD >
5- < meta charset ="UTF-8 ">
6- < title > SocialView Javadoc</ title >
7- < link rel ="stylesheet " href ="style.css ">
8- </ HEAD >
9- < BODY >
10- < a href ="https://github.com/hendraanggrian/socialview "> GitHub</ a > < br />
11- < br />
12- < p > Welcome to SocialView Javadoc!</ p >
13- < h3 > Libraries</ h3 >
14- < table >
15- < tbody >
16- < tr >
17- < td >
18- < p > < a href ="socialview-core/index.html "> socialview-core</ a > </ p >
19- </ td >
20- < td >
21- </ td >
22- </ tr >
23- < tr >
24- < td >
25- < p > < a href ="socialview-commons/index.html "> socialview-commons</ a > </ p >
26- </ td >
27- < td >
28- </ td >
29- </ tr >
30- </ tbody >
31- </ table >
32- </ BODY >
33- </ HTML >
60+ // auto-complete widgets
61+ implementation "com.hendraanggrian.appcompat:socialview-autocomplete:$version"
62+ }
63+ </ code > </ pre >
64+
65+ < h2 > Usage</ h2 >
66+
67+ < h3 > Core</ h3 >
68+
69+ < p >
70+ Core library contains < code > SocialTextView</ code > , < code > SocialEditText</ code > and helper class
71+ applies these behavior into any < code > TextView</ code > .
72+ </ p >
73+
74+ < pre > < code class ="language-xml "> <com.hendraanggrian.appcompat.socialview.widget.SocialTextView
75+ android:id="@+id/textView"
76+ android:layout_width="match_parent"
77+ android:layout_height="wrap_content"
78+ android:text="#hashtag and @mention."
79+ app:socialFlags="hashtag|mention"
80+ app:hashtagColor="@color/blue"
81+ app:mentionColor="@color/red"/>
82+ </ code > </ pre >
83+
84+ < p >
85+ See < a href ="https://github.com/HendraAnggrian/socialview/blob/master/socialview/res/values/attrs.xml "> attrs.xml</ a >
86+ for full list of available attributes.
87+ </ p >
88+
89+ < p > Modify its state and set listeners programmatically.</ p >
90+
91+ < pre > < code class ="language-java "> textView.setMentionEnabled(false);
92+ textView.setHashtagColor(Color.RED);
93+ textView.setOnHashtagClickListener(new SocialView.OnClickListener() {
94+ @Override
95+ public void invoke(SocialView socialView, String s) {
96+ // do something
97+ }
98+ });
99+ </ code > </ pre >
100+
101+ < h3 > Auto-complete</ h3 >
102+
103+ < p >
104+ Extended library comes with < code > SocialAutoCompleteTextView</ code > .
105+ </ p >
106+
107+ < pre > < code class ="language-xml "> <com.hendraanggrian.appcompat.socialview.widget.SocialAutoCompleteTextView
108+ android:id="@+id/textView"
109+ android:layout_width="match_parent"
110+ android:layout_height="wrap_content"
111+ android:hint="What's on your mind?"
112+ app:socialFlags="hyperlink"
113+ app:hyperlinkColor="@color/green"/>
114+ </ code > </ pre >
115+
116+ < p >
117+ To display suggestions, it is required to < code > setHashtagAdapter()</ code >
118+ and < code > setMentionAdapter()</ code > .
119+ </ p >
120+
121+ < pre > < code class ="language-java "> ArrayAdapter<Hashtag> hashtagAdapter = new HashtagAdapter(getContext());
122+ hashtagAdapter.add(new Hashtag("follow"));
123+ hashtagAdapter.add(new Hashtag("followme", 1000));
124+ hashtagAdapter.add(new Hashtag("followmeorillkillyou", 500));
125+ textView.setHashtagAdapter(hashtagAdapter);
126+
127+ ArrayAdapter<Mention> mentionAdapter = new MentionAdapter(getContext());
128+ mentionAdapter.add(new Mention("dirtyhobo"));
129+ mentionAdapter.add(new Mention("hobo", "Regular Hobo", R.mipmap.ic_launcher));
130+ mentionAdapter.add(new Mention("hendraanggrian", "Hendra Anggrian",
131+ "https://avatars0.githubusercontent.com/u/11507430?v=3&s=460"));
132+ textView.setMentionAdapter(mentionAdapter);
133+ </ code > </ pre >
134+
135+ < p >
136+ To customize hashtag or mention adapter, create a custom adapter using
137+ customized < code > SocialAdapter</ code > or write your own < code > ArrayAdapter</ code > .
138+ </ p >
139+
140+ < blockquote >
141+
142+ < p > Custom adapters are experimental, see sample for example.</ p >
143+
144+ </ blockquote >
145+
146+ < pre > < code class ="language-java "> public class Person {
147+ public final String name;
148+
149+ public Person(String name) {
150+ this.name = name;
151+ }
152+ }
153+
154+ // easier
155+ public class PersonAdapter extends SocialAdapter<Person> {
156+ public PersonAdapter(@NonNull Context context) {
157+ super(context, R.layout.item_person, R.id.textview_person);
158+ }
159+
160+ @Override
161+ public String convertToString(Person $receiver) {
162+ return $receiver.name;
163+ }
164+
165+ @Override
166+ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
167+ // ...
168+ }
169+ }
170+
171+ // this works too
172+ public class PersonAdapter extends ArrayAdapter<Person> {
173+ // your own adapter layout, view holder, data binding
174+ // and of course, filtering logic
175+ }
176+ </ code > </ pre >
177+
178+ < p > Then, use the custom adapter.</ p >
179+
180+ < pre > < code class ="language-java "> ArrayAdapter<Person> adapter = new PersonAdapter(getContext());
181+ adapter.add(personA);
182+ adapter.add(personB);
183+ textView.setMentionAdapter(adapter);
184+ </ code > </ pre >
185+
186+ < footer class ="site-footer ">
187+ < span class ="site-footer-owner "> < a href ="https://github.com/hendraanggrian/socialview/ "> socialview</ a > is maintained by < a href ="https://github.com/hendraanggrian/ "> Hendra Anggrian</ a > </ span > < span class ="site-footer-credits "> Hosted on GitHub Pages — Theme by < a href ="https://github.com/jasonlong/cayman-theme/ "> jasonlong</ a > </ span >
188+ </ footer >
189+ </ section >
190+ </ body >
191+ </ html >
0 commit comments