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

Using Broadcast helpers...

This commit is contained in:
Sebastian Kaspari 2010-03-24 19:35:46 +01:00
parent c66eeecb0b
commit b482afa305
4 changed files with 18 additions and 13 deletions

View File

@ -35,7 +35,7 @@ import org.yaaic.R;
import org.yaaic.Yaaic;
import org.yaaic.db.Database;
import org.yaaic.exception.ValidationException;
import org.yaaic.model.Broadcast;
import org.yaaic.model.Extra;
import org.yaaic.model.Identity;
import org.yaaic.model.Server;
import org.yaaic.model.Status;
@ -64,10 +64,10 @@ public class AddServerActivity extends Activity implements OnClickListener
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
Bundle extras = getIntent().getExtras();
if (extras != null && extras.containsKey(Broadcast.EXTRA_SERVER)) {
if (extras != null && extras.containsKey(Extra.SERVER)) {
// Request to edit an existing server
Database db = new Database(this);
this.server = db.getServerById(extras.getInt(Broadcast.EXTRA_SERVER));
this.server = db.getServerById(extras.getInt(Extra.SERVER));
db.close();
// Set server values

View File

@ -48,6 +48,7 @@ import org.yaaic.irc.IRCService;
import org.yaaic.layout.NonScalingBackgroundDrawable;
import org.yaaic.listener.ServerListener;
import org.yaaic.model.Broadcast;
import org.yaaic.model.Extra;
import org.yaaic.model.Server;
import org.yaaic.model.Status;
import org.yaaic.receiver.ServerReceiver;
@ -202,7 +203,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
}
else {
Intent intent = new Intent(this, AddServerActivity.class);
intent.putExtra(Broadcast.EXTRA_SERVER, serverId);
intent.putExtra(Extra.SERVER, serverId);
startActivityForResult(intent, 0);
}
}

View File

@ -24,6 +24,7 @@ import org.jibble.pircbot.IrcException;
import org.jibble.pircbot.NickAlreadyInUseException;
import org.yaaic.R;
import org.yaaic.model.Broadcast;
import org.yaaic.model.Extra;
import org.yaaic.model.Message;
import org.yaaic.model.Server;
import org.yaaic.model.ServerInfo;
@ -83,8 +84,8 @@ public class IRCBinder extends Binder
server.setStatus(Status.DISCONNECTED);
Intent sIntent = new Intent(Broadcast.SERVER_UPDATE);
sIntent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
Intent sIntent = Broadcast.createServerIntent(Broadcast.SERVER_UPDATE, server.getId());
service.sendBroadcast(sIntent);
IRCConnection connection = getService().getConnection(server.getId());
@ -103,9 +104,11 @@ public class IRCBinder extends Binder
message.setIcon(R.drawable.error);
server.getConversation(ServerInfo.DEFAULT_NAME).addMessage(message);
Intent cIntent = new Intent(Broadcast.CONVERSATION_MESSAGE);
cIntent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
cIntent.putExtra(Broadcast.EXTRA_CONVERSATION, ServerInfo.DEFAULT_NAME);
Intent cIntent = Broadcast.createConversationIntent(
Extra.CONVERSATION,
server.getId(),
ServerInfo.DEFAULT_NAME
);
service.sendBroadcast(cIntent);
}
}

View File

@ -26,6 +26,7 @@ import android.content.Intent;
import org.yaaic.listener.ConversationListener;
import org.yaaic.model.Broadcast;
import org.yaaic.model.Extra;
/**
* A channel receiver for receiving channel updates
@ -60,7 +61,7 @@ public class ConversationReceiver extends BroadcastReceiver
@Override
public void onReceive(Context context, Intent intent)
{
int serverId = intent.getExtras().getInt(Broadcast.EXTRA_SERVER);
int serverId = intent.getExtras().getInt(Extra.SERVER);
if (serverId != this.serverId) {
return;
}
@ -68,11 +69,11 @@ public class ConversationReceiver extends BroadcastReceiver
String action = intent.getAction();
if (action.equals(Broadcast.CONVERSATION_MESSAGE)) {
listener.onConversationMessage(intent.getExtras().getString(Broadcast.EXTRA_CONVERSATION));
listener.onConversationMessage(intent.getExtras().getString(Extra.CONVERSATION));
} else if (action.equals(Broadcast.CONVERSATION_NEW)) {
listener.onNewConversation(intent.getExtras().getString(Broadcast.EXTRA_CONVERSATION));
listener.onNewConversation(intent.getExtras().getString(Extra.CONVERSATION));
} else if (action.equals(Broadcast.CONVERSATION_REMOVE)) {
listener.onRemoveConversation(intent.getExtras().getString(Broadcast.EXTRA_CONVERSATION));
listener.onRemoveConversation(intent.getExtras().getString(Extra.CONVERSATION));
}
}