mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-26 19:02:17 -05:00
CommandParser and CommandHandlers: Use Broadcast helper methods
This commit is contained in:
parent
976ef4f598
commit
c66eeecb0b
@ -143,9 +143,12 @@ public class CommandParser
|
||||
Message usageMessage = new Message("Syntax: " + command.getUsage());
|
||||
conversation.addMessage(usageMessage);
|
||||
|
||||
Intent intent = new Intent(Broadcast.CONVERSATION_MESSAGE);
|
||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
|
||||
Intent intent = Broadcast.createConversationIntent(
|
||||
Broadcast.CONVERSATION_MESSAGE,
|
||||
server.getId(),
|
||||
conversation.getName()
|
||||
);
|
||||
|
||||
service.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
@ -162,9 +165,12 @@ public class CommandParser
|
||||
message.setColor(Message.COLOR_RED);
|
||||
conversation.addMessage(message);
|
||||
|
||||
Intent intent = new Intent(Broadcast.CONVERSATION_MESSAGE);
|
||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
|
||||
Intent intent = Broadcast.createConversationIntent(
|
||||
Broadcast.CONVERSATION_MESSAGE,
|
||||
server.getId(),
|
||||
conversation.getName()
|
||||
);
|
||||
|
||||
service.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
@ -55,9 +55,11 @@ public class CloseHandler extends BaseHandler
|
||||
if (conversation.getType() == Conversation.TYPE_QUERY) {
|
||||
server.removeConversation(conversation.getName());
|
||||
|
||||
Intent intent = new Intent(Broadcast.CONVERSATION_REMOVE);
|
||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
|
||||
Intent intent = Broadcast.createConversationIntent(
|
||||
Broadcast.CONVERSATION_REMOVE,
|
||||
server.getId(),
|
||||
conversation.getName()
|
||||
);
|
||||
service.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
@ -47,9 +47,11 @@ public class EchoHandler extends BaseHandler
|
||||
Message message = new Message(BaseHandler.mergeParams(params));
|
||||
conversation.addMessage(message);
|
||||
|
||||
Intent intent = new Intent(Broadcast.CONVERSATION_MESSAGE);
|
||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
|
||||
Intent intent = Broadcast.createConversationIntent(
|
||||
Broadcast.CONVERSATION_REMOVE,
|
||||
server.getId(),
|
||||
conversation.getName()
|
||||
);
|
||||
service.sendBroadcast(intent);
|
||||
} else {
|
||||
throw new CommandException("Text is missing");
|
||||
|
@ -56,9 +56,11 @@ public class MeHandler extends BaseHandler
|
||||
message.setIcon(R.drawable.action);
|
||||
server.getConversation(conversation.getName()).addMessage(message);
|
||||
|
||||
Intent intent = new Intent(Broadcast.CONVERSATION_MESSAGE);
|
||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
|
||||
Intent intent = Broadcast.createConversationIntent(
|
||||
Broadcast.CONVERSATION_REMOVE,
|
||||
server.getId(),
|
||||
conversation.getName()
|
||||
);
|
||||
service.sendBroadcast(intent);
|
||||
|
||||
service.getConnection(server.getId()).sendAction(conversation.getName(), action);
|
||||
|
@ -60,9 +60,11 @@ public class NamesHandler extends BaseHandler
|
||||
message.setColor(Message.COLOR_YELLOW);
|
||||
conversation.addMessage(message);
|
||||
|
||||
Intent intent = new Intent(Broadcast.CONVERSATION_MESSAGE);
|
||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
|
||||
Intent intent = Broadcast.createConversationIntent(
|
||||
Broadcast.CONVERSATION_REMOVE,
|
||||
server.getId(),
|
||||
conversation.getName()
|
||||
);
|
||||
service.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
|
@ -53,9 +53,11 @@ public class NoticeHandler extends BaseHandler
|
||||
message.setIcon(R.drawable.info);
|
||||
conversation.addMessage(message);
|
||||
|
||||
Intent intent = new Intent(Broadcast.CONVERSATION_MESSAGE);
|
||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
|
||||
Intent intent = Broadcast.createConversationIntent(
|
||||
Broadcast.CONVERSATION_REMOVE,
|
||||
server.getId(),
|
||||
conversation.getName()
|
||||
);
|
||||
service.sendBroadcast(intent);
|
||||
|
||||
service.getConnection(server.getId()).sendNotice(params[1], text);
|
||||
|
@ -59,9 +59,11 @@ public class QueryHandler extends BaseHandler
|
||||
|
||||
server.addConversationl(new Query(params[1]));
|
||||
|
||||
Intent intent = new Intent(Broadcast.CONVERSATION_NEW);
|
||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||
intent.putExtra(Broadcast.EXTRA_CONVERSATION, params[1]);
|
||||
Intent intent = Broadcast.createConversationIntent(
|
||||
Broadcast.CONVERSATION_REMOVE,
|
||||
server.getId(),
|
||||
conversation.getName()
|
||||
);
|
||||
service.sendBroadcast(intent);
|
||||
} else {
|
||||
throw new CommandException("Invalid number of params");
|
||||
|
Loading…
Reference in New Issue
Block a user