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

Do more work on threads

This commit is contained in:
Sebastian Kaspari 2010-03-20 22:39:42 +01:00
parent 6da41e633a
commit 2a679baf6e

View File

@ -138,13 +138,17 @@ public class ConversationActivity extends Activity implements ServiceConnection,
} }
// Fill view with messages that have been buffered while paused // Fill view with messages that have been buffered while paused
for (Conversation conversation : server.getConversations()) { new Thread() {
while (conversation.hasBufferedMessages()) { public void run() {
if (conversation.getMessageListAdapter() != null) { for (Conversation conversation : server.getConversations()) {
conversation.getMessageListAdapter().addMessage(conversation.pollBufferedMessage()); while (conversation.hasBufferedMessages()) {
if (conversation.getMessageListAdapter() != null) {
conversation.getMessageListAdapter().addMessage(conversation.pollBufferedMessage());
}
}
} }
} }
} }.start();
} }
/** /**
@ -361,9 +365,9 @@ public class ConversationActivity extends Activity implements ServiceConnection,
if (conversation != null) { if (conversation != null) {
if (!text.trim().startsWith("/")) { if (!text.trim().startsWith("/")) {
if (conversation.getType() != Conversation.TYPE_SERVER) { if (conversation.getType() != Conversation.TYPE_SERVER) {
String nickname = this.binder.getService().getConnection(serverId).getNick(); String nickname = binder.getService().getConnection(serverId).getNick();
conversation.addMessage(new Message("<" + nickname + "> " + text)); conversation.addMessage(new Message("<" + nickname + "> " + text));
this.binder.getService().getConnection(serverId).sendMessage(conversation.getName(), text); binder.getService().getConnection(serverId).sendMessage(conversation.getName(), text);
} else { } else {
Message message = new Message("You can only chat from within a channel or a query"); Message message = new Message("You can only chat from within a channel or a query");
message.setColor(Message.COLOR_YELLOW); message.setColor(Message.COLOR_YELLOW);
@ -387,11 +391,16 @@ public class ConversationActivity extends Activity implements ServiceConnection,
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) protected void onActivityResult(int requestCode, int resultCode, Intent data)
{ {
// currently there's only the "join channel" activity
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
// currently there's only the "join channel" activity final String channel = data.getExtras().getString("channel");
binder.getService().getConnection(serverId).joinChannel(
data.getExtras().getString("channel") // run on own thread
); new Thread() {
public void run() {
binder.getService().getConnection(serverId).joinChannel(channel);
}
}.start();
} }
} }