1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-26 19:02:17 -05:00

ConversationActivity: register the receivers as early as possible, otherwise we may loose a broadcast message

This commit is contained in:
Sebastian Kaspari 2010-04-12 20:01:42 +02:00
parent a79794ba1d
commit 1271326483

View File

@ -126,6 +126,15 @@ public class ConversationActivity extends Activity implements ServiceConnection,
@Override @Override
public void onResume() public void onResume()
{ {
// register the receivers as early as possible, otherwise we may loose a broadcast message
channelReceiver = new ConversationReceiver(server.getId(), this);
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_MESSAGE));
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_NEW));
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_REMOVE));
serverReceiver = new ServerReceiver(this);
registerReceiver(serverReceiver, new IntentFilter(Broadcast.SERVER_UPDATE));
super.onResume(); super.onResume();
((ImageView) findViewById(R.id.status)).setImageResource(server.getStatusIcon()); ((ImageView) findViewById(R.id.status)).setImageResource(server.getStatusIcon());
@ -136,14 +145,6 @@ public class ConversationActivity extends Activity implements ServiceConnection,
startService(intent); startService(intent);
bindService(intent, this, 0); bindService(intent, this, 0);
channelReceiver = new ConversationReceiver(server.getId(), this);
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_MESSAGE));
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_NEW));
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_REMOVE));
serverReceiver = new ServerReceiver(this);
registerReceiver(serverReceiver, new IntentFilter(Broadcast.SERVER_UPDATE));
if (!server.isConnected()) { if (!server.isConnected()) {
((EditText) findViewById(R.id.input)).setEnabled(false); ((EditText) findViewById(R.id.input)).setEnabled(false);
} else { } else {