mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-15 13:35:09 -05:00
Remove channel views on part
This commit is contained in:
parent
b87501622c
commit
e7a903851e
@ -106,12 +106,15 @@ public class DeckAdapter extends BaseAdapter
|
|||||||
*
|
*
|
||||||
* @param channel
|
* @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();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set single channel view
|
* Set single channel view
|
||||||
|
@ -52,9 +52,6 @@ public class MessageListAdapter extends BaseAdapter
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
|
|
||||||
// Render channel name as first message in channel
|
// 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) {
|
if (conversation.getType() != Conversation.TYPE_SERVER) {
|
||||||
Message header = new Message(conversation.getName());
|
Message header = new Message(conversation.getName());
|
||||||
header.setColor(Message.COLOR_RED);
|
header.setColor(Message.COLOR_RED);
|
||||||
@ -65,6 +62,8 @@ public class MessageListAdapter extends BaseAdapter
|
|||||||
messages.add(message.renderTextView(context));
|
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();
|
conversation.clearBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ public class IRCConnection extends PircBot
|
|||||||
debug("Part", target + " " + sender);
|
debug("Part", target + " " + sender);
|
||||||
|
|
||||||
if (sender.equals(getNick())) {
|
if (sender.equals(getNick())) {
|
||||||
// We pareted a channel
|
// We parted a channel
|
||||||
server.removeConversation(target);
|
server.removeConversation(target);
|
||||||
|
|
||||||
Intent intent = new Intent(Broadcast.CONVERSATION_REMOVE);
|
Intent intent = new Intent(Broadcast.CONVERSATION_REMOVE);
|
||||||
|
@ -31,6 +31,8 @@ import java.util.LinkedList;
|
|||||||
*/
|
*/
|
||||||
public abstract class Conversation
|
public abstract class Conversation
|
||||||
{
|
{
|
||||||
|
public static final String TAG = "Yaaic/Conversation";
|
||||||
|
|
||||||
public static final int TYPE_CHANNEL = 1;
|
public static final int TYPE_CHANNEL = 1;
|
||||||
public static final int TYPE_QUERY = 2;
|
public static final int TYPE_QUERY = 2;
|
||||||
public static final int TYPE_SERVER = 3;
|
public static final int TYPE_SERVER = 3;
|
||||||
|
@ -61,7 +61,7 @@ public class ChannelReceiver extends BroadcastReceiver
|
|||||||
} else if (action.equals(Broadcast.CONVERSATION_NEW)) {
|
} else if (action.equals(Broadcast.CONVERSATION_NEW)) {
|
||||||
listener.onNewConversation(intent.getExtras().getString(Broadcast.EXTRA_CONVERSATION));
|
listener.onNewConversation(intent.getExtras().getString(Broadcast.EXTRA_CONVERSATION));
|
||||||
} else if (action.equals(Broadcast.CONVERSATION_REMOVE)) {
|
} else if (action.equals(Broadcast.CONVERSATION_REMOVE)) {
|
||||||
intent.getExtras().getString(Broadcast.EXTRA_CONVERSATION);
|
listener.onRemoveConversation(intent.getExtras().getString(Broadcast.EXTRA_CONVERSATION));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On channel message
|
* On conversation message
|
||||||
*/
|
*/
|
||||||
public void onConversationMessage(String target)
|
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)
|
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)
|
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)
|
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id)
|
||||||
{
|
{
|
||||||
Log.d(TAG, "Selected channel: " + position);
|
|
||||||
|
|
||||||
Conversation conversation = deckAdapter.getItem(position);
|
Conversation conversation = deckAdapter.getItem(position);
|
||||||
|
|
||||||
MessageListView canvas = deckAdapter.renderConversation(conversation, switcher);
|
MessageListView canvas = deckAdapter.renderConversation(conversation, switcher);
|
||||||
canvas.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
canvas.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
||||||
canvas.setDelegateTouchEvents(false); // Do not delegate
|
canvas.setDelegateTouchEvents(false); // Do not delegate
|
||||||
|
|
||||||
deckAdapter.setSwitched(conversation.getName(), canvas);
|
deckAdapter.setSwitched(conversation.getName(), canvas);
|
||||||
switcher.addView(canvas);
|
switcher.addView(canvas);
|
||||||
switcher.showNext();
|
switcher.showNext();
|
||||||
|
Loading…
Reference in New Issue
Block a user