Skip to content

Commit fb42faf

Browse files
committed
Merge branch 'master' of github.com:firebase/FirebaseUI-Android
* 'master' of github.com:firebase/FirebaseUI-Android: (22 commits) Made ChatHolder and Chat public fix typo Added a title to the code lab Re-did app screenshots, blurred namespace in URL Added screenshots for "Enable login" Screenshots from current app Screenshots for "Show the messages" Re-indent images, since they're showing up as code Added images for "send a message" Added images for connecting the app to Firebase Fixed path to 2_7.png Fixed image syntax Un-indent image markup Fixed TOC links Added screenshots for section 2 Fix parameter order for FirebaseListAdapter (again) Hyperlink sections, switch to textual gradle.build instructions Added first few images More indentation woes, and corrected hyperlink syntax Fixed code indentation ...
2 parents 40478d0 + a061489 commit fb42faf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+534
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Next, we need to create a subclass of the `FirebaseListAdapter` with the correct
142142
Firebase.setAndroidContext(this);
143143
Firebase ref = new Firebase("https://nanochat.firebaseio.com");
144144

145-
mAdapter = new FirebaseListAdapter<ChatMessage>(ChatMessage.class, android.R.layout.two_line_list_item, this, ref) {
145+
mAdapter = new FirebaseListAdapter<ChatMessage>(this, ChatMessage.class, android.R.layout.two_line_list_item, ref) {
146146
@Override
147147
protected void populateView(View view, ChatMessage chatMessage) {
148148
((TextView)view.findViewById(android.R.id.text1)).setText(chatMessage.getName());

app/app.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898
<orderEntry type="library" exported="" name="recyclerview-v7-22.2.1" level="project" />
9999
<orderEntry type="library" exported="" name="tubesock-0.0.11" level="project" />
100100
<orderEntry type="library" exported="" name="jackson-annotations-2.2.2" level="project" />
101-
<orderEntry type="library" exported="" name="firebase-client-android-2.3.1" level="project" />
102101
<orderEntry type="library" exported="" name="support-annotations-22.2.1" level="project" />
102+
<orderEntry type="library" exported="" name="firebase-client-android-2.3.1" level="project" />
103103
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
104104
<orderEntry type="module" module-name="library" exported="" />
105105
</component>
Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.firebase.uidemo;
22

3-
import android.app.Activity;
43
import android.graphics.Color;
54
import android.os.Bundle;
65
import android.support.v7.app.AppCompatActivity;
@@ -14,6 +13,7 @@
1413
import android.widget.TextView;
1514

1615
import com.firebase.client.Firebase;
16+
import com.firebase.client.FirebaseError;
1717
import com.firebase.ui.FirebaseRecyclerViewAdapter;
1818

1919

@@ -23,7 +23,7 @@ protected void onCreate(Bundle savedInstanceState) {
2323
super.onCreate(savedInstanceState);
2424
setContentView(R.layout.recycler_view_demo);
2525

26-
final Firebase ref = new Firebase("https://nanochat.firebaseio.com");
26+
final Firebase ref = new Firebase("https://firebaseui.firebaseio.com/chat");
2727

2828
final String name = "Android User";
2929
final Button sendButton = (Button) findViewById(R.id.sendButton);
@@ -36,61 +36,67 @@ protected void onCreate(Bundle savedInstanceState) {
3636
@Override
3737
public void onClick(View v) {
3838
Chat chat = new Chat(name, messageEdit.getText().toString());
39-
ref.push().setValue(chat);
39+
ref.push().setValue(chat, new Firebase.CompletionListener() {
40+
@Override
41+
public void onComplete(FirebaseError firebaseError, Firebase firebase) {
42+
if (firebaseError != null) {
43+
Log.e("FirebaseUI.chat", firebaseError.toString());
44+
}
45+
}
46+
});
4047
messageEdit.setText("");
4148
}
4249
});
4350

4451
FirebaseRecyclerViewAdapter<Chat, ChatHolder> adapter = new FirebaseRecyclerViewAdapter<Chat, ChatHolder>(Chat.class, android.R.layout.two_line_list_item, ChatHolder.class, ref) {
4552
@Override
4653
public void populateViewHolder(ChatHolder chatView, Chat chat) {
47-
chatView.messageText.setText(chat.getMessage());
48-
chatView.messageText.setPadding(10, 0, 10, 0);
49-
chatView.nameText.setText(chat.getName());
50-
chatView.nameText.setPadding(10, 0, 10, 15);
54+
chatView.textView.setText(chat.getText());
55+
chatView.textView.setPadding(10, 0, 10, 0);
56+
chatView.nameView.setText(chat.getName());
57+
chatView.nameView.setPadding(10, 0, 10, 15);
5158
if (chat.getName().equals(name)) {
52-
chatView.messageText.setGravity(Gravity.END);
53-
chatView.nameText.setGravity(Gravity.END);
54-
chatView.nameText.setTextColor(Color.parseColor("#8BC34A"));
59+
chatView.textView.setGravity(Gravity.END);
60+
chatView.nameView.setGravity(Gravity.END);
61+
chatView.nameView.setTextColor(Color.parseColor("#8BC34A"));
5562
} else {
56-
chatView.nameText.setTextColor(Color.parseColor("#00BCD4"));
63+
chatView.nameView.setTextColor(Color.parseColor("#00BCD4"));
5764
}
5865
}
5966
};
6067

6168
messages.setAdapter(adapter);
62-
6369
}
6470

6571

66-
static class Chat {
72+
public static class Chat {
6773
String name;
68-
String message;
74+
String text;
6975

7076
public Chat() {
7177
}
7278

7379
public Chat(String name, String message) {
7480
this.name = name;
75-
this.message = message;
81+
this.text = message;
7682
}
7783

7884
public String getName() {
7985
return name;
8086
}
8187

82-
public String getMessage() {
83-
return message;
88+
public String getText() {
89+
return text;
8490
}
8591
}
8692

87-
static class ChatHolder extends RecyclerView.ViewHolder {
88-
TextView nameText, messageText;
93+
public static class ChatHolder extends RecyclerView.ViewHolder {
94+
TextView nameView, textView;
8995

9096
public ChatHolder(View itemView) {
9197
super(itemView);
92-
nameText = (TextView) itemView.findViewById(android.R.id.text2);
93-
messageText = (TextView) itemView.findViewById(android.R.id.text1);
98+
nameView = (TextView) itemView.findViewById(android.R.id.text2);
99+
textView = (TextView) itemView.findViewById(android.R.id.text1);
94100
}
95101
}
96102
}

app/src/main/res/layout/recycler_view_demo.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns:tools="http://schemas.android.com/tools"
44
android:layout_width="match_parent"
55
android:layout_height="match_parent"
6+
67
tools:context=".RecyclerViewDemoActivity">
78

89
<android.support.v7.widget.RecyclerView

0 commit comments

Comments
 (0)