1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-15 05:25:05 -05:00

Remove channel views on part

This commit is contained in:
Sebastian Kaspari 2010-03-11 01:10:21 +01:00
parent b87501622c
commit e7a903851e
6 changed files with 23 additions and 15 deletions

View File

@ -106,12 +106,15 @@ public class DeckAdapter extends BaseAdapter
*
* @param channel
*/
public void removeItem(Conversation conversation)
public void removeItem(String target)
{
conversations.remove(conversation);
int position = getPositionByName(target);
if (position != -1) {
conversations.remove(position);
notifyDataSetChanged();
}
}
/**
* Set single channel view

View File

@ -52,9 +52,6 @@ public class MessageListAdapter extends BaseAdapter
this.context = context;
// Render channel name as first message in channel
// XXX: There will be no messages shown if channel is empty, why?
if (conversation.getType() != Conversation.TYPE_SERVER) {
Message header = new Message(conversation.getName());
header.setColor(Message.COLOR_RED);
@ -65,6 +62,8 @@ public class MessageListAdapter extends BaseAdapter
messages.add(message.renderTextView(context));
}
// XXX: We don't want to clear the buffer, we want to add only
// buffered messages that are not already added (history)
conversation.clearBuffer();
}

View File

@ -368,7 +368,7 @@ public class IRCConnection extends PircBot
debug("Part", target + " " + sender);
if (sender.equals(getNick())) {
// We pareted a channel
// We parted a channel
server.removeConversation(target);
Intent intent = new Intent(Broadcast.CONVERSATION_REMOVE);

View File

@ -31,6 +31,8 @@ import java.util.LinkedList;
*/
public abstract class Conversation
{
public static final String TAG = "Yaaic/Conversation";
public static final int TYPE_CHANNEL = 1;
public static final int TYPE_QUERY = 2;
public static final int TYPE_SERVER = 3;

View File

@ -61,7 +61,7 @@ public class ChannelReceiver extends BroadcastReceiver
} else if (action.equals(Broadcast.CONVERSATION_NEW)) {
listener.onNewConversation(intent.getExtras().getString(Broadcast.EXTRA_CONVERSATION));
} else if (action.equals(Broadcast.CONVERSATION_REMOVE)) {
intent.getExtras().getString(Broadcast.EXTRA_CONVERSATION);
listener.onRemoveConversation(intent.getExtras().getString(Broadcast.EXTRA_CONVERSATION));
}
}

View File

@ -227,7 +227,7 @@ public class ConversationActivity extends Activity implements ServiceConnection,
}
/**
* On channel message
* On conversation message
*/
public void onConversationMessage(String target)
{
@ -256,7 +256,7 @@ public class ConversationActivity extends Activity implements ServiceConnection,
}
/**
* On new channel
* On new conversation
*/
public void onNewConversation(String target)
{
@ -269,11 +269,15 @@ public class ConversationActivity extends Activity implements ServiceConnection,
}
/**
* On channel remove
* On conversation remove
*/
public void onRemoveConversation(String target)
{
// XXX: Implement me :)
deckAdapter.removeItem(target);
if (deckAdapter.isSwitched()) {
onBackPressed();
}
}
/**
@ -292,16 +296,16 @@ public class ConversationActivity extends Activity implements ServiceConnection,
}
/**
* On Channel item clicked
* On conversation item clicked
*/
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id)
{
Log.d(TAG, "Selected channel: " + position);
Conversation conversation = deckAdapter.getItem(position);
MessageListView canvas = deckAdapter.renderConversation(conversation, switcher);
canvas.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
canvas.setDelegateTouchEvents(false); // Do not delegate
deckAdapter.setSwitched(conversation.getName(), canvas);
switcher.addView(canvas);
switcher.showNext();