1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-26 02:42:16 -05:00

DeckAdapter now uses conversations instead of channels

This commit is contained in:
Sebastian Kaspari 2010-03-10 20:45:56 +01:00
parent d9755926ec
commit 5517660011

View File

@ -22,7 +22,7 @@ package org.yaaic.adapter;
import java.util.LinkedList; import java.util.LinkedList;
import org.yaaic.model.Channel; import org.yaaic.model.Conversation;
import org.yaaic.view.MessageListView; import org.yaaic.view.MessageListView;
import android.view.View; import android.view.View;
@ -40,7 +40,7 @@ public class DeckAdapter extends BaseAdapter
{ {
public static final String TAG = "Yaaic/DeckAdapter"; public static final String TAG = "Yaaic/DeckAdapter";
private LinkedList<Channel> channels = new LinkedList<Channel>(); private LinkedList<Conversation> conversations = new LinkedList<Conversation>();
private MessageListView currentView; private MessageListView currentView;
private String currentChannel; private String currentChannel;
@ -49,16 +49,16 @@ public class DeckAdapter extends BaseAdapter
*/ */
public int getCount() public int getCount()
{ {
return channels.size(); return conversations.size();
} }
/** /**
* Get item at position * Get item at position
*/ */
public Channel getItem(int position) public Conversation getItem(int position)
{ {
if (position >= 0 && position < channels.size()) { if (position >= 0 && position < conversations.size()) {
return channels.get(position); return conversations.get(position);
} }
return null; return null;
} }
@ -77,9 +77,9 @@ public class DeckAdapter extends BaseAdapter
* @param channel Name of the channel * @param channel Name of the channel
* @param view The view object * @param view The view object
*/ */
public void addItem(Channel channel) public void addItem(Conversation conversation)
{ {
channels.add(channel); conversations.add(conversation);
notifyDataSetChanged(); notifyDataSetChanged();
} }
@ -92,8 +92,8 @@ public class DeckAdapter extends BaseAdapter
*/ */
public int getPositionByName(String name) public int getPositionByName(String name)
{ {
for (int i = 0; i < channels.size(); i++) { for (int i = 0; i < conversations.size(); i++) {
if (channels.get(i).getName().equals(name)) { if (conversations.get(i).getName().equals(name)) {
return i; return i;
} }
} }
@ -106,9 +106,9 @@ public class DeckAdapter extends BaseAdapter
* *
* @param channel * @param channel
*/ */
public void removeItem(Channel channel) public void removeItem(Conversation conversation)
{ {
channels.remove(channel); conversations.remove(conversation);
notifyDataSetChanged(); notifyDataSetChanged();
} }
@ -159,21 +159,21 @@ public class DeckAdapter extends BaseAdapter
*/ */
public View getView(int position, View convertView, ViewGroup parent) public View getView(int position, View convertView, ViewGroup parent)
{ {
Channel channel = getItem(position); Conversation conversation = getItem(position);
return renderChannel(channel, parent); return renderConversation(conversation, parent);
} }
/** /**
* Render a channel view (MessageListView) * Render a conversation view (MessageListView)
* *
* @param channel The channel of the view * @param channel The conversation of the view
* @param parent The parent view (context) * @param parent The parent view (context)
* @return The rendered MessageListView * @return The rendered MessageListView
*/ */
public MessageListView renderChannel(Channel channel, ViewGroup parent) public MessageListView renderConversation(Conversation conversation, ViewGroup parent)
{ {
MessageListView list = new MessageListView(parent.getContext()); MessageListView list = new MessageListView(parent.getContext());
list.setAdapter(new MessageListAdapter(channel, parent.getContext())); list.setAdapter(new MessageListAdapter(conversation, parent.getContext()));
list.setDivider(null); list.setDivider(null);
list.setLayoutParams(new Gallery.LayoutParams( list.setLayoutParams(new Gallery.LayoutParams(