mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
translate error codes into alerts or toasts where appropriate.
This commit is contained in:
parent
1e253c0210
commit
5cf9472642
2 changed files with 42 additions and 0 deletions
|
@ -216,6 +216,11 @@
|
|||
<string name="msg_relay_all_here">All players are here.</string>
|
||||
<string name="title_relay_status">Connection status.</string>
|
||||
|
||||
<string name="relay_alert">Connection error</string>
|
||||
<string name="msg_too_many">You are providing more players than the host expects.</string>
|
||||
<string name="msg_no_room">No host has registered a room by that name.</string>
|
||||
<string name="msg_dup_room">Another host has already registered a room using that name. Rename yours or retry later.</string>
|
||||
<string name="msg_lost_other">The relay has lost contact with another device in this game.</string>
|
||||
|
||||
<!-- These do not require localization -->
|
||||
<string name="key_color_tiles">key_color_tiles</string>
|
||||
|
|
|
@ -313,5 +313,42 @@ public class CommsTransport extends Thread implements TransportProcs {
|
|||
public void relayErrorProc( XWRELAY_ERROR relayErr )
|
||||
{
|
||||
Utils.logf( "relayErrorProc called; got " + relayErr.toString() );
|
||||
|
||||
int strID = 0;
|
||||
int how = TOAST;
|
||||
|
||||
switch ( relayErr ) {
|
||||
case TOO_MANY:
|
||||
strID = R.string.msg_too_many;
|
||||
how = DIALOG;
|
||||
break;
|
||||
case NO_ROOM:
|
||||
strID = R.string.msg_no_room;
|
||||
how = DIALOG;
|
||||
break;
|
||||
case DUP_ROOM:
|
||||
strID = R.string.msg_dup_room;
|
||||
how = DIALOG;
|
||||
break;
|
||||
case LOST_OTHER:
|
||||
case OTHER_DISCON:
|
||||
strID = R.string.msg_lost_other;
|
||||
break;
|
||||
|
||||
case OLDFLAGS:
|
||||
case BADPROTO:
|
||||
case RELAYBUSY:
|
||||
case SHUTDOWN:
|
||||
case TIMEOUT:
|
||||
case HEART_YOU:
|
||||
case HEART_OTHER:
|
||||
break;
|
||||
}
|
||||
|
||||
if ( 0 != strID ) {
|
||||
String str = m_context.getString( strID );
|
||||
Message.obtain( m_handler, how, R.string.relay_alert,
|
||||
0, str ).sendToTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue