Skip to content

Commit 4c43a35

Browse files
committed
Added JavaDoc code samples
1 parent f09aaff commit 4c43a35

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

app/app.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
8787
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
8888
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
89+
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
8990
</content>
9091
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
9192
<orderEntry type="sourceFolder" forTests="false" />

library/src/main/java/com/firebase/ui/FirebaseListAdapter.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@
4343
* instance of your list item mLayout and an instance your class that holds your data. Simply populate the view however
4444
* you like and this class will handle updating the list as the data changes.
4545
*
46+
* <blockquote><pre>
47+
* {@code
48+
* Firebase ref = new Firebase("https://<yourapp>.firebaseio.com");
49+
* ListAdapter adapter = new FirebaseListAdapter<ChatMessage>(this, ChatMessage.class, android.R.layout.two_line_list_item, mRef)
50+
* {
51+
* protected void populateView(View view, ChatMessage chatMessage)
52+
* {
53+
* ((TextView)view.findViewById(android.R.id.text1)).setText(chatMessage.getName());
54+
* ((TextView)view.findViewById(android.R.id.text2)).setText(chatMessage.getMessage());
55+
* }
56+
* };
57+
* listView.setListAdapter(adapter);
58+
* }
59+
* </pre></blockquote>
60+
*
4661
* @param <T> The class type to use as a model for the data contained in the children of the given Firebase location
4762
*/
4863
public abstract class FirebaseListAdapter<T> extends BaseAdapter {

library/src/main/java/com/firebase/ui/FirebaseRecyclerViewAdapter.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,35 @@
4747
* To use this class in your app, subclass it passing in all required parameters and implement the
4848
* populateViewHolder method.
4949
*
50+
* <blockquote><pre>
51+
* {@code
52+
* private static class ChatMessageViewHolder extends RecyclerView.ViewHolder {
53+
* TextView messageText;
54+
* TextView nameText;
55+
*
56+
* public ChatMessageViewHolder(View itemView) {
57+
* super(itemView);
58+
* nameText = (TextView)itemView.findViewById(android.R.id.text1);
59+
* messageText = (TextView) itemView.findViewById(android.R.id.text2);
60+
* }
61+
* }
62+
*
63+
* FirebaseRecyclerViewAdapter<ChatMessage, ChatMessageViewHolder> adapter;
64+
* ref = new Firebase("https://<yourapp>.firebaseio.com");
65+
*
66+
* RecyclerView recycler = (RecyclerView) findViewById(R.id.messages_recycler);
67+
* recycler.setHasFixedSize(true);
68+
* recycler.setLayoutManager(new LinearLayoutManager(this));
69+
*
70+
* adapter = new FirebaseRecyclerViewAdapter<ChatMessage, ChatMessageViewHolder>(ChatMessage.class, android.R.layout.two_line_list_item, ChatMessageViewHolder.class, mRef) {
71+
* public void populateViewHolder(ChatMessageViewHolder chatMessageViewHolder, ChatMessage chatMessage) {
72+
* chatMessageViewHolder.nameText.setText(chatMessage.getName());
73+
* chatMessageViewHolder.messageText.setText(chatMessage.getMessage());
74+
* }
75+
* };
76+
* recycler.setAdapter(mAdapter);
77+
*
78+
*
5079
* @param <T> The Java class that maps to the type of objects stored in the Firebase location.
5180
* @param <VH> The ViewHolder class that contains the Views in the layout that is shown for each object.
5281
*/

0 commit comments

Comments
 (0)