use of net.rim.device.api.ui.container.MainScreen in project Samples-for-Java by blackberry.
the class StartGameScreen method gameMessage.
public void gameMessage(ProtocolMessage message) {
if (message instanceof ProtocolMessageMasterBid) {
ProtocolMessageMasterBid other_bid = (ProtocolMessageMasterBid) message;
int device_status = 0;
boolean initialised = false;
if (my_bid.getBid() > other_bid.getBid()) {
Utilities.log("XXXX won the bid: player 1");
device_status = Constants.PLAYER_1;
initialised = true;
} else {
if (my_bid.getBid() < other_bid.getBid()) {
Utilities.log("XXXX lost the bid: player 2");
device_status = Constants.PLAYER_2;
initialised = true;
} else {
Utilities.popupMessage("It didn't work, try again!");
}
}
if (initialised) {
try {
proto.disableMessaging();
} catch (NFCException e) {
Utilities.log("XXXX StartGameScreen:" + e.getClass().getName() + ":" + e.getMessage());
Utilities.popupMessage("We had a problem, please try again");
}
final int player_no = device_status;
final MainScreen next_screen;
if (player_no == Constants.PLAYER_2) {
next_screen = GameScreen.getInstance(player_no);
} else {
next_screen = new SymbolSelectionScreen();
}
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
UiApplication.getUiApplication().pushScreen(next_screen);
}
});
}
}
}
Aggregations