From e378c6570b8318641a032d591e40e96af2e40d2f Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Wed, 6 Feb 2013 23:14:52 +0100 Subject: [PATCH] Update all broadcast sending to use LocalBroadcastManager. This breaks a lot as the receiving part is not changed yet. But this is a branch anyways ... so let's break stuff! --- application/src/org/yaaic/Yaaic.java | 17 +-- .../yaaic/activity/ConversationActivity.java | 12 ++- .../src/org/yaaic/command/CommandParser.java | 3 +- .../yaaic/command/handler/AMsgHandler.java | 3 +- .../yaaic/command/handler/CloseHandler.java | 8 +- .../org/yaaic/command/handler/DCCHandler.java | 3 +- .../yaaic/command/handler/EchoHandler.java | 3 +- .../yaaic/command/handler/HelpHandler.java | 11 +- .../org/yaaic/command/handler/MeHandler.java | 3 +- .../org/yaaic/command/handler/MsgHandler.java | 3 +- .../yaaic/command/handler/NamesHandler.java | 3 +- .../yaaic/command/handler/NoticeHandler.java | 3 +- .../yaaic/command/handler/QueryHandler.java | 3 +- .../src/org/yaaic/irc/IRCConnection.java | 101 +++++++++--------- application/src/org/yaaic/irc/IRCService.java | 7 +- 15 files changed, 100 insertions(+), 83 deletions(-) diff --git a/application/src/org/yaaic/Yaaic.java b/application/src/org/yaaic/Yaaic.java index b740a8fe..92eb7ae3 100644 --- a/application/src/org/yaaic/Yaaic.java +++ b/application/src/org/yaaic/Yaaic.java @@ -28,10 +28,11 @@ import org.yaaic.model.Server; import android.content.Context; +import android.support.v4.content.LocalBroadcastManager; /** * Global Master Class :) - * + * * @author Sebastian Kaspari */ public class Yaaic @@ -51,7 +52,7 @@ private Yaaic() /** * Load servers from database - * + * * @param context */ public void loadServers(Context context) @@ -61,14 +62,14 @@ public void loadServers(Context context) servers = db.getServers(); db.close(); - // context.sendBroadcast(new Intent(Broadcast.SERVER_UPDATE)); + // LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Broadcast.SERVER_UPDATE)); serversLoaded = true; } } /** * Get global Yaaic instance - * + * * @return the global Yaaic instance */ public static Yaaic getInstance() @@ -82,7 +83,7 @@ public static Yaaic getInstance() /** * Get server by id - * + * * @return Server object with given unique id */ public Server getServerById(int serverId) @@ -92,7 +93,7 @@ public Server getServerById(int serverId) /** * Remove server with given unique id from list - * + * * @param serverId */ public void removeServerById(int serverId) @@ -102,7 +103,7 @@ public void removeServerById(int serverId) /** * Set servers - * + * * @param servers */ public void setServers(HashMap servers) @@ -130,7 +131,7 @@ public void updateServer(Server server) /** * Get list of servers - * + * * @return list of servers */ public ArrayList getServersAsArrayList() diff --git a/application/src/org/yaaic/activity/ConversationActivity.java b/application/src/org/yaaic/activity/ConversationActivity.java index f7b1aa10..6b2c4376 100644 --- a/application/src/org/yaaic/activity/ConversationActivity.java +++ b/application/src/org/yaaic/activity/ConversationActivity.java @@ -65,6 +65,7 @@ import android.os.Handler; import android.os.IBinder; import android.speech.RecognizerIntent; +import android.support.v4.content.LocalBroadcastManager; import android.support.v4.view.ViewPager; import android.text.InputType; import android.text.method.TextKeyListener; @@ -715,11 +716,12 @@ public void run() { server.addConversation(query); Intent intent = Broadcast.createConversationIntent( - Broadcast.CONVERSATION_NEW, - server.getId(), - nicknameWithoutPrefix - ); - binder.getService().sendBroadcast(intent); + Broadcast.CONVERSATION_NEW, + server.getId(), + nicknameWithoutPrefix + ); + + LocalBroadcastManager.getInstance(binder.getService()).sendBroadcast(intent); } break; case User.ACTION_OP: diff --git a/application/src/org/yaaic/command/CommandParser.java b/application/src/org/yaaic/command/CommandParser.java index cfdd7877..69c73538 100644 --- a/application/src/org/yaaic/command/CommandParser.java +++ b/application/src/org/yaaic/command/CommandParser.java @@ -55,6 +55,7 @@ import org.yaaic.model.Server; import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; /** * Parser for commands @@ -195,7 +196,7 @@ public void handleClientCommand(String type, String[] params, Server server, Con conversation.getName() ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } } } diff --git a/application/src/org/yaaic/command/handler/AMsgHandler.java b/application/src/org/yaaic/command/handler/AMsgHandler.java index bd05ddd3..60229438 100644 --- a/application/src/org/yaaic/command/handler/AMsgHandler.java +++ b/application/src/org/yaaic/command/handler/AMsgHandler.java @@ -33,6 +33,7 @@ import android.content.Context; import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; /** * Command: /amsg @@ -65,7 +66,7 @@ public void execute(String[] params, Server server, Conversation conversation, I currentConversation.getName() ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); service.getConnection(server.getId()).sendMessage(currentConversation.getName(), text); } diff --git a/application/src/org/yaaic/command/handler/CloseHandler.java b/application/src/org/yaaic/command/handler/CloseHandler.java index 7727e645..03609c39 100644 --- a/application/src/org/yaaic/command/handler/CloseHandler.java +++ b/application/src/org/yaaic/command/handler/CloseHandler.java @@ -30,12 +30,13 @@ import android.content.Context; import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; /** * Command: /close - * + * * Closes the current window - * + * * @author Sebastian Kaspari */ public class CloseHandler extends BaseHandler @@ -62,7 +63,8 @@ public void execute(String[] params, Server server, Conversation conversation, I server.getId(), conversation.getName() ); - service.sendBroadcast(intent); + + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } } } diff --git a/application/src/org/yaaic/command/handler/DCCHandler.java b/application/src/org/yaaic/command/handler/DCCHandler.java index 9ed7378c..aa2d983f 100644 --- a/application/src/org/yaaic/command/handler/DCCHandler.java +++ b/application/src/org/yaaic/command/handler/DCCHandler.java @@ -32,6 +32,7 @@ import org.yaaic.model.Server; import android.content.Context; +import android.support.v4.content.LocalBroadcastManager; /** * Command: /dcc SEND @@ -63,7 +64,7 @@ public void execute(String[] params, Server server, Conversation conversation, I message.setColor(Message.COLOR_GREY); conversation.addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), conversation.getName()) ); } else { diff --git a/application/src/org/yaaic/command/handler/EchoHandler.java b/application/src/org/yaaic/command/handler/EchoHandler.java index 054ad530..c0b42f63 100644 --- a/application/src/org/yaaic/command/handler/EchoHandler.java +++ b/application/src/org/yaaic/command/handler/EchoHandler.java @@ -31,6 +31,7 @@ import android.content.Context; import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; /** * Command: /echo @@ -54,7 +55,7 @@ public void execute(String[] params, Server server, Conversation conversation, I server.getId(), conversation.getName() ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } else { throw new CommandException(service.getString(R.string.text_missing)); } diff --git a/application/src/org/yaaic/command/handler/HelpHandler.java b/application/src/org/yaaic/command/handler/HelpHandler.java index 689c904e..86c03c33 100644 --- a/application/src/org/yaaic/command/handler/HelpHandler.java +++ b/application/src/org/yaaic/command/handler/HelpHandler.java @@ -35,10 +35,11 @@ import android.content.Context; import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; /** * Command: /help - * + * * @author Karol Gliniecki * @author Sebastian Kaspari */ @@ -61,7 +62,7 @@ public void execute(String[] params, Server server, Conversation conversation, I /** * Show all available commands - * + * * @param conversation * @param server * @param service @@ -100,12 +101,12 @@ private void showAllCommands(IRCService service, Server server, Conversation con conversation.getName() ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } /** * Show details of a single command - * + * * @param conversation * @param server * @param service @@ -129,7 +130,7 @@ private void showCommandDetails(IRCService service, Server server, Conversation conversation.getName() ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } else { throw new CommandException(service.getString(R.string.unknown_command, command)); } diff --git a/application/src/org/yaaic/command/handler/MeHandler.java b/application/src/org/yaaic/command/handler/MeHandler.java index 1f3fef0a..679262bf 100644 --- a/application/src/org/yaaic/command/handler/MeHandler.java +++ b/application/src/org/yaaic/command/handler/MeHandler.java @@ -31,6 +31,7 @@ import android.content.Context; import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; /** * Command: /me @@ -62,7 +63,7 @@ public void execute(String[] params, Server server, Conversation conversation, I server.getId(), conversation.getName() ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); service.getConnection(server.getId()).sendAction(conversation.getName(), action); } else { diff --git a/application/src/org/yaaic/command/handler/MsgHandler.java b/application/src/org/yaaic/command/handler/MsgHandler.java index 03a274e5..f397882d 100644 --- a/application/src/org/yaaic/command/handler/MsgHandler.java +++ b/application/src/org/yaaic/command/handler/MsgHandler.java @@ -31,6 +31,7 @@ import android.content.Context; import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; /** * Command: /msg @@ -63,7 +64,7 @@ public void execute(String[] params, Server server, Conversation conversation, I targetConversation.getName() ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } } else { throw new CommandException(service.getString(R.string.invalid_number_of_params)); diff --git a/application/src/org/yaaic/command/handler/NamesHandler.java b/application/src/org/yaaic/command/handler/NamesHandler.java index 1946daa7..b1f3001d 100644 --- a/application/src/org/yaaic/command/handler/NamesHandler.java +++ b/application/src/org/yaaic/command/handler/NamesHandler.java @@ -32,6 +32,7 @@ import android.content.Context; import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; /** * Command: /names @@ -70,7 +71,7 @@ public void execute(String[] params, Server server, Conversation conversation, I server.getId(), conversation.getName() ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } /** diff --git a/application/src/org/yaaic/command/handler/NoticeHandler.java b/application/src/org/yaaic/command/handler/NoticeHandler.java index be8e3518..e9b61dfa 100644 --- a/application/src/org/yaaic/command/handler/NoticeHandler.java +++ b/application/src/org/yaaic/command/handler/NoticeHandler.java @@ -31,6 +31,7 @@ import android.content.Context; import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; /** * Command: /notice @@ -59,7 +60,7 @@ public void execute(String[] params, Server server, Conversation conversation, I server.getId(), conversation.getName() ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); service.getConnection(server.getId()).sendNotice(params[1], text); } else { diff --git a/application/src/org/yaaic/command/handler/QueryHandler.java b/application/src/org/yaaic/command/handler/QueryHandler.java index 4d10a413..c2c20946 100644 --- a/application/src/org/yaaic/command/handler/QueryHandler.java +++ b/application/src/org/yaaic/command/handler/QueryHandler.java @@ -31,6 +31,7 @@ import android.content.Context; import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; /** * Command: /query @@ -68,7 +69,7 @@ public void execute(String[] params, Server server, Conversation conversation, I server.getId(), query.getName() ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } else { throw new CommandException(service.getString(R.string.invalid_number_of_params)); } diff --git a/application/src/org/yaaic/irc/IRCConnection.java b/application/src/org/yaaic/irc/IRCConnection.java index 27c7c30f..157b94d8 100644 --- a/application/src/org/yaaic/irc/IRCConnection.java +++ b/application/src/org/yaaic/irc/IRCConnection.java @@ -43,6 +43,7 @@ import org.yaaic.model.Status; import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; import android.util.Log; /** @@ -169,7 +170,7 @@ public void onConnect() ignoreMOTD = service.getSettings().isIgnoreMOTDEnabled(); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createServerIntent(Broadcast.SERVER_UPDATE, server.getId()) ); @@ -193,7 +194,7 @@ public void onConnect() identify(server.getAuthentication().getNickservPassword()); } - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } /** @@ -246,7 +247,7 @@ public void onRegister() ServerInfo.DEFAULT_NAME ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } /** * On channel action @@ -278,7 +279,7 @@ protected void onAction(String sender, String login, String hostname, String tar server.getId(), queryNick ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } else { conversation.addMessage(message); @@ -287,7 +288,7 @@ protected void onAction(String sender, String login, String hostname, String tar server.getId(), queryNick ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } if (sender.equals(this.getNick())) { @@ -341,7 +342,7 @@ protected void onDeop(String target, String sourceNick, String sourceLogin, Stri target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } /** @@ -361,7 +362,7 @@ protected void onDeVoice(String target, String sourceNick, String sourceLogin, S target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } /** @@ -380,7 +381,7 @@ protected void onInvite(String targetNick, String sourceNick, String sourceLogin server.getId(), server.getSelectedConversation() ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } else { // Someone is invited Message message = new Message(service.getString(R.string.message_invite_someone, sourceNick, targetNick, target)); @@ -391,7 +392,7 @@ protected void onInvite(String targetNick, String sourceNick, String sourceLogin server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } } @@ -412,7 +413,7 @@ protected void onJoin(String target, String sender, String login, String hostnam server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } else if (service.getSettings().showJoinPartAndQuit()) { Message message = new Message( service.getString(R.string.message_join, sender), @@ -428,7 +429,7 @@ protected void onJoin(String target, String sender, String login, String hostnam server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } } @@ -448,7 +449,7 @@ protected void onKick(String target, String kickerNick, String kickerLogin, Stri server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } else { Message message = new Message(service.getString(R.string.message_kick, kickerNick, recipientNick)); message.setColor(Message.COLOR_GREEN); @@ -459,7 +460,7 @@ protected void onKick(String target, String kickerNick, String kickerLogin, Stri server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } } @@ -496,7 +497,7 @@ protected void onMessage(String target, String sender, String login, String host server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } /** @@ -514,7 +515,7 @@ protected void onMode(String target, String sourceNick, String sourceLogin, Stri Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE); intent.putExtra(Broadcast.EXTRA_SERVER, server.getId()); intent.putExtra(Broadcast.EXTRA_CHANNEL, target); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); */ } @@ -538,7 +539,7 @@ protected void onNickChange(String oldNick, String login, String hostname, Strin ServerInfo.DEFAULT_NAME ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } Vector channels = getChannelsByNickname(newNick); @@ -553,7 +554,7 @@ protected void onNickChange(String oldNick, String login, String hostname, Strin server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } } @@ -586,7 +587,7 @@ protected void onNotice(String sourceNick, String sourceLogin, String sourceHost server.getId(), conversation.getName() ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } /** @@ -605,7 +606,7 @@ protected void onOp(String target, String sourceNick, String sourceLogin, String server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } /** @@ -624,7 +625,7 @@ protected void onPart(String target, String sender, String login, String hostnam server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } else if (service.getSettings().showJoinPartAndQuit()) { Message message = new Message( service.getString(R.string.message_part, sender), @@ -640,7 +641,7 @@ protected void onPart(String target, String sender, String login, String hostnam server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } } @@ -670,7 +671,7 @@ protected void onPrivateMessage(String sender, String login, String hostname, St server.getId(), queryNick ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } else { conversation.addMessage(message); @@ -679,7 +680,7 @@ protected void onPrivateMessage(String sender, String login, String hostname, St server.getId(), queryNick ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } if (sender.equals(this.getNick())) { @@ -732,7 +733,7 @@ protected void onQuit(String sourceNick, String sourceLogin, String sourceHostna server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } // Look if there's a query to update @@ -753,7 +754,7 @@ protected void onQuit(String sourceNick, String sourceLogin, String sourceHostna server.getId(), conversation.getName() ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } } } @@ -782,7 +783,7 @@ public void onTopic(String target, String topic, String setBy, long date, boolea server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); // update the displayed conversation title if necessary intent = Broadcast.createConversationIntent( @@ -790,7 +791,7 @@ public void onTopic(String target, String topic, String setBy, long date, boolea server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } /** @@ -818,7 +819,7 @@ protected void onVoice(String target, String sourceNick, String sourceLogin, Str server.getId(), target ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } /** @@ -831,7 +832,7 @@ protected void onRemoveChannelKey(String target, String sourceNick, String sourc message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -846,7 +847,7 @@ protected void onSetChannelKey(String target, String sourceNick, String sourceLo message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -861,7 +862,7 @@ protected void onSetSecret(String target, String sourceNick, String sourceLogin, message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -876,7 +877,7 @@ protected void onRemoveSecret(String target, String sourceNick, String sourceLog message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -891,7 +892,7 @@ protected void onSetChannelLimit(String target, String sourceNick, String source message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -906,7 +907,7 @@ protected void onRemoveChannelLimit(String target, String sourceNick, String sou message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -921,7 +922,7 @@ protected void onSetChannelBan(String target, String sourceNick, String sourceLo message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -936,7 +937,7 @@ protected void onRemoveChannelBan(String target, String sourceNick, String sourc message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -951,7 +952,7 @@ protected void onSetTopicProtection(String target, String sourceNick, String sou message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -966,7 +967,7 @@ protected void onRemoveTopicProtection(String target, String sourceNick, String message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -981,7 +982,7 @@ protected void onSetNoExternalMessages(String target, String sourceNick, String message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -996,7 +997,7 @@ protected void onRemoveNoExternalMessages(String target, String sourceNick, Stri message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -1011,7 +1012,7 @@ protected void onSetInviteOnly(String target, String sourceNick, String sourceLo message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -1026,7 +1027,7 @@ protected void onRemoveInviteOnly(String target, String sourceNick, String sourc message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -1041,7 +1042,7 @@ protected void onSetModerated(String target, String sourceNick, String sourceLog message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -1056,7 +1057,7 @@ protected void onRemoveModerated(String target, String sourceNick, String source message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -1071,7 +1072,7 @@ protected void onSetPrivate(String target, String sourceNick, String sourceLogin message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -1086,7 +1087,7 @@ protected void onRemovePrivate(String target, String sourceNick, String sourceLo message.setColor(Message.COLOR_BLUE); server.getConversation(target).addMessage(message); - service.sendBroadcast( + LocalBroadcastManager.getInstance(service).sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target) ); } @@ -1107,7 +1108,7 @@ protected void onUnknown(String line) server.getId(), ServerInfo.DEFAULT_NAME ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } /** @@ -1156,7 +1157,7 @@ protected void onServerResponse(int code, String response) server.getId(), ServerInfo.DEFAULT_NAME ); - service.sendBroadcast(intent); + LocalBroadcastManager.getInstance(service).sendBroadcast(intent); } /** @@ -1180,7 +1181,7 @@ public void onDisconnect() service.notifyDisconnected(server.getTitle()); Intent sIntent = Broadcast.createServerIntent(Broadcast.SERVER_UPDATE, server.getId()); - service.sendBroadcast(sIntent); + LocalBroadcastManager.getInstance(service).sendBroadcast(sIntent); Collection conversations = server.getConversations(); @@ -1195,7 +1196,7 @@ public void onDisconnect() server.getId(), conversation.getName() ); - service.sendBroadcast(cIntent); + LocalBroadcastManager.getInstance(service).sendBroadcast(cIntent); } synchronized(isQuittingLock) { diff --git a/application/src/org/yaaic/irc/IRCService.java b/application/src/org/yaaic/irc/IRCService.java index 398d08a3..8d8e1fef 100644 --- a/application/src/org/yaaic/irc/IRCService.java +++ b/application/src/org/yaaic/irc/IRCService.java @@ -50,6 +50,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.os.SystemClock; +import android.support.v4.content.LocalBroadcastManager; /** * The background service for managing the irc connections @@ -136,7 +137,7 @@ public void onCreate() db.close(); // Broadcast changed server list - sendBroadcast(new Intent(Broadcast.SERVER_UPDATE)); + LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(Broadcast.SERVER_UPDATE)); } /** @@ -483,7 +484,7 @@ public void run() { server.setStatus(Status.DISCONNECTED); Intent sIntent = Broadcast.createServerIntent(Broadcast.SERVER_UPDATE, serverId); - sendBroadcast(sIntent); + LocalBroadcastManager.getInstance(IRCService.this).sendBroadcast(sIntent); IRCConnection connection = getConnection(serverId); @@ -520,7 +521,7 @@ public void run() { serverId, ServerInfo.DEFAULT_NAME ); - sendBroadcast(cIntent); + LocalBroadcastManager.getInstance(IRCService.this).sendBroadcast(cIntent); } } }.start();