aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-06-17 19:14:27 -0700
committerScott Jackson <daneren2005@gmail.com>2014-06-17 19:14:27 -0700
commit4b8a3d998d4a8a75b6e54069f018bc19d7ba6cd9 (patch)
tree32c647a89a0432911961854090944f9ef1af9eee /src
parent4be11780670cdbc4b7491f3a9656f681f0514c2d (diff)
downloaddsub-4b8a3d998d4a8a75b6e54069f018bc19d7ba6cd9.tar.gz
dsub-4b8a3d998d4a8a75b6e54069f018bc19d7ba6cd9.tar.bz2
dsub-4b8a3d998d4a8a75b6e54069f018bc19d7ba6cd9.zip
#364 Rework chat layouts + add avatars
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/fragments/ChatFragment.java4
-rw-r--r--src/github/daneren2005/dsub/view/ChatAdapter.java10
2 files changed, 11 insertions, 3 deletions
diff --git a/src/github/daneren2005/dsub/fragments/ChatFragment.java b/src/github/daneren2005/dsub/fragments/ChatFragment.java
index f017b632..d51be830 100644
--- a/src/github/daneren2005/dsub/fragments/ChatFragment.java
+++ b/src/github/daneren2005/dsub/fragments/ChatFragment.java
@@ -124,7 +124,7 @@ public class ChatFragment extends SubsonicFragment {
}
}
- ChatAdapter chatAdapter = new ChatAdapter(context, messageList);
+ ChatAdapter chatAdapter = new ChatAdapter(context, messageList, getImageLoader());
chatListView.setAdapter(chatAdapter);
}
setTitle(R.string.button_bar_chat);
@@ -216,7 +216,7 @@ public class ChatFragment extends SubsonicFragment {
Collections.reverse(result);
messageList.addAll(result);
- ChatAdapter chatAdapter = new ChatAdapter(context, messageList);
+ ChatAdapter chatAdapter = new ChatAdapter(context, messageList, getImageLoader());
chatListView.setAdapter(chatAdapter);
}
}
diff --git a/src/github/daneren2005/dsub/view/ChatAdapter.java b/src/github/daneren2005/dsub/view/ChatAdapter.java
index c7bc13f2..0ce757a9 100644
--- a/src/github/daneren2005/dsub/view/ChatAdapter.java
+++ b/src/github/daneren2005/dsub/view/ChatAdapter.java
@@ -6,10 +6,12 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
+import android.widget.ImageView;
import android.widget.TextView;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.activity.SubsonicActivity;
import github.daneren2005.dsub.domain.ChatMessage;
+import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.util.UserUtil;
import github.daneren2005.dsub.util.Util;
@@ -22,14 +24,16 @@ public class ChatAdapter extends ArrayAdapter<ChatMessage> {
private final SubsonicActivity activity;
private ArrayList<ChatMessage> messages;
+ private final ImageLoader imageLoader;
private static final String phoneRegex = "1?\\W*([2-9][0-8][0-9])\\W*([2-9][0-9]{2})\\W*([0-9]{4})"; //you can just place your support phone here
private static final Pattern phoneMatcher = Pattern.compile(phoneRegex);
- public ChatAdapter(SubsonicActivity activity, ArrayList<ChatMessage> messages) {
+ public ChatAdapter(SubsonicActivity activity, ArrayList<ChatMessage> messages, ImageLoader imageLoader) {
super(activity, R.layout.chat_item, messages);
this.activity = activity;
this.messages = messages;
+ this.imageLoader = imageLoader;
}
@Override
@@ -74,6 +78,7 @@ public class ChatAdapter extends ArrayAdapter<ChatMessage> {
holder.message = messageView;
holder.username = usernameView;
holder.time = timeView;
+ holder.avatar = (ImageView) convertView.findViewById(R.id.chat_avatar);
convertView.setTag(holder);
}
@@ -89,6 +94,8 @@ public class ChatAdapter extends ArrayAdapter<ChatMessage> {
holder.message.setText(messageText);
holder.time.setText(messageTimeFormatted);
+ imageLoader.loadAvatar(activity, holder.avatar, messageUser);
+
return convertView;
}
@@ -97,5 +104,6 @@ public class ChatAdapter extends ArrayAdapter<ChatMessage> {
TextView message;
TextView username;
TextView time;
+ ImageView avatar;
}
}