mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
rename method: sendResult -> postEvent
This commit is contained in:
parent
aa420ce4d1
commit
9c14e0e858
6 changed files with 30 additions and 28 deletions
|
@ -403,7 +403,7 @@ public class BTService extends XWService {
|
|||
boolean cameOn = intent.getBooleanExtra( RADIO_KEY, false );
|
||||
MultiEvent evt = cameOn? MultiEvent.BT_ENABLED
|
||||
: MultiEvent.BT_DISABLED;
|
||||
sendResult( evt );
|
||||
postEvent( evt );
|
||||
if ( cameOn ) {
|
||||
GameUtils.resendAllIf( this, CommsConnType.COMMS_CONN_BT,
|
||||
false );
|
||||
|
@ -594,7 +594,7 @@ public class BTService extends XWService {
|
|||
}
|
||||
break;
|
||||
case MESG_GAMEGONE:
|
||||
sendResult( MultiEvent.MESSAGE_NOGAME, gameID );
|
||||
postEvent( MultiEvent.MESSAGE_NOGAME, gameID );
|
||||
result = BTCmd.MESG_ACCPT;
|
||||
break;
|
||||
default:
|
||||
|
@ -765,7 +765,7 @@ public class BTService extends XWService {
|
|||
if ( sendPing( dev, 0 ) ) { // did we get a reply?
|
||||
addAddr( dev );
|
||||
if ( null != event ) {
|
||||
sendResult( event, dev.getName() );
|
||||
postEvent( event, dev.getName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -794,7 +794,7 @@ public class BTService extends XWService {
|
|||
} else {
|
||||
gotReply = BTCmd.PONG == reply;
|
||||
if ( gotReply && is.readBoolean() ) {
|
||||
sendResult( MultiEvent.MESSAGE_NOGAME, gameID );
|
||||
postEvent( MultiEvent.MESSAGE_NOGAME, gameID );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -847,20 +847,20 @@ public class BTService extends XWService {
|
|||
}
|
||||
|
||||
if ( null == reply ) {
|
||||
sendResult( MultiEvent.APP_NOT_FOUND_BT, dev.getName() );
|
||||
postEvent( MultiEvent.APP_NOT_FOUND_BT, dev.getName() );
|
||||
} else {
|
||||
switch ( reply ) {
|
||||
case BAD_PROTO:
|
||||
sendBadProto( socket );
|
||||
break;
|
||||
case INVITE_ACCPT:
|
||||
sendResult( MultiEvent.NEWGAME_SUCCESS, elem.m_gameID );
|
||||
postEvent( MultiEvent.NEWGAME_SUCCESS, elem.m_gameID );
|
||||
break;
|
||||
case INVITE_DUPID:
|
||||
sendResult( MultiEvent.NEWGAME_DUP_REJECTED, dev.getName() );
|
||||
postEvent( MultiEvent.NEWGAME_DUP_REJECTED, dev.getName() );
|
||||
break;
|
||||
default:
|
||||
sendResult( MultiEvent.NEWGAME_FAILURE, elem.m_gameID );
|
||||
postEvent( MultiEvent.NEWGAME_FAILURE, elem.m_gameID );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -943,10 +943,10 @@ public class BTService extends XWService {
|
|||
|
||||
if ( null != evt ) {
|
||||
String btName = nameForAddr( m_adapter, elem.m_btAddr );
|
||||
sendResult( evt, elem.m_gameID, 0, btName );
|
||||
postEvent( evt, elem.m_gameID, 0, btName );
|
||||
if ( ! success ) {
|
||||
int failCount = elem.incrFailCount();
|
||||
sendResult( MultiEvent.MESSAGE_RESEND, btName,
|
||||
postEvent( MultiEvent.MESSAGE_RESEND, btName,
|
||||
RESEND_TIMEOUT, failCount );
|
||||
}
|
||||
}
|
||||
|
@ -966,7 +966,7 @@ public class BTService extends XWService {
|
|||
iter.remove();
|
||||
} else if ( elem.failCountExceeded() ) {
|
||||
String btName = nameForAddr( m_adapter, elem.m_btAddr );
|
||||
sendResult( MultiEvent.MESSAGE_FAILOUT, btName );
|
||||
postEvent( MultiEvent.MESSAGE_FAILOUT, btName );
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
@ -1037,7 +1037,7 @@ public class BTService extends XWService {
|
|||
for ( int ii = 0; ii < size; ++ii ) {
|
||||
btNames[ii] = nameForAddr( m_adapter, btAddrs[ii] );
|
||||
}
|
||||
sendResult( MultiEvent.SCAN_DONE, (Object)btAddrs, (Object)btNames );
|
||||
postEvent( MultiEvent.SCAN_DONE, (Object)btAddrs, (Object)btNames );
|
||||
}
|
||||
|
||||
private void initAddrs()
|
||||
|
@ -1147,7 +1147,7 @@ public class BTService extends XWService {
|
|||
GameUtils.postInvitedNotification( this, nli.gameID(), body,
|
||||
rowid );
|
||||
|
||||
sendResult( MultiEvent.BT_GAME_CREATED, rowid );
|
||||
postEvent( MultiEvent.BT_GAME_CREATED, rowid );
|
||||
}
|
||||
} else {
|
||||
result = BTCmd.INVITE_DUPID;
|
||||
|
@ -1182,13 +1182,13 @@ public class BTService extends XWService {
|
|||
DbgUtils.logex( ioe );
|
||||
++s_errCount;
|
||||
// if ( 0 == s_errCount % 10 ) {
|
||||
sendResult( MultiEvent.BT_ERR_COUNT, s_errCount );
|
||||
postEvent( MultiEvent.BT_ERR_COUNT, s_errCount );
|
||||
// }
|
||||
}
|
||||
|
||||
private void sendBadProto( BluetoothSocket socket )
|
||||
{
|
||||
sendResult( MultiEvent.BAD_PROTO_BT, socket.getRemoteDevice().getName() );
|
||||
postEvent( MultiEvent.BAD_PROTO_BT, socket.getRemoteDevice().getName() );
|
||||
}
|
||||
|
||||
private void updateStatusOut( boolean success )
|
||||
|
|
|
@ -59,6 +59,7 @@ public class MultiService {
|
|||
private static final String ACTION_FETCH_DICT = "_afd";
|
||||
private static final String FOR_MISSING_DICT = "_fmd";
|
||||
|
||||
// Shouldn't this be a Set?
|
||||
private MultiEventListener m_li;
|
||||
|
||||
// these do not currently pass between devices so they can change.
|
||||
|
@ -105,7 +106,7 @@ public class MultiService {
|
|||
}
|
||||
}
|
||||
|
||||
public void sendResult( MultiEvent event, Object ... args )
|
||||
public void postEvent( MultiEvent event, Object ... args )
|
||||
{
|
||||
synchronized( this ) {
|
||||
if ( null != m_li ) {
|
||||
|
|
|
@ -707,7 +707,7 @@ public class RelayService extends XWService
|
|||
DbgUtils.logi( TAG, "relay unvailable for another %d seconds",
|
||||
unavail );
|
||||
String str = getVLIString( dis );
|
||||
sendResult( MultiEvent.RELAY_ALERT, str );
|
||||
postEvent( MultiEvent.RELAY_ALERT, str );
|
||||
break;
|
||||
case XWPDEV_ALERT:
|
||||
str = getVLIString( dis );
|
||||
|
|
|
@ -521,11 +521,11 @@ public class SMSService extends XWService {
|
|||
break;
|
||||
case DEATH:
|
||||
gameID = dis.readInt();
|
||||
sendResult( MultiEvent.MESSAGE_NOGAME, gameID );
|
||||
postEvent( MultiEvent.MESSAGE_NOGAME, gameID );
|
||||
break;
|
||||
case ACK:
|
||||
gameID = dis.readInt();
|
||||
sendResult( MultiEvent.NEWGAME_SUCCESS,
|
||||
postEvent( MultiEvent.NEWGAME_SUCCESS,
|
||||
gameID );
|
||||
break;
|
||||
default:
|
||||
|
@ -546,7 +546,7 @@ public class SMSService extends XWService {
|
|||
byte[] rest = new byte[buffer.length - 4];
|
||||
System.arraycopy( buffer, 4, rest, 0, rest.length );
|
||||
if ( tryAssemble( senderPhone, id, index, count, rest ) ) {
|
||||
sendResult( MultiEvent.SMS_RECEIVE_OK );
|
||||
postEvent( MultiEvent.SMS_RECEIVE_OK );
|
||||
} else {
|
||||
DbgUtils.logw( TAG, "SMSService: receiveBuffer(): bogus message from"
|
||||
+ " phone %s", senderPhone );
|
||||
|
@ -602,7 +602,7 @@ public class SMSService extends XWService {
|
|||
if ( SMS_PROTO_VERSION < proto ) {
|
||||
DbgUtils.logw( TAG, "SMSService.disAssemble: bad proto %d from %s;"
|
||||
+ " dropping", proto, senderPhone );
|
||||
sendResult( MultiEvent.BAD_PROTO_SMS, senderPhone );
|
||||
postEvent( MultiEvent.BAD_PROTO_SMS, senderPhone );
|
||||
} else if ( gotPort != myPort ) {
|
||||
DbgUtils.logd( TAG, "disAssemble(): received on port %d"
|
||||
+ " but expected %d", gotPort, myPort );
|
||||
|
@ -712,17 +712,17 @@ public class SMSService extends XWService {
|
|||
{
|
||||
switch ( getResultCode() ) {
|
||||
case Activity.RESULT_OK:
|
||||
sendResult( MultiEvent.SMS_SEND_OK );
|
||||
postEvent( MultiEvent.SMS_SEND_OK );
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_RADIO_OFF:
|
||||
DbgUtils.showf( SMSService.this, "NO RADIO!!!" );
|
||||
sendResult( MultiEvent.SMS_SEND_FAILED_NORADIO );
|
||||
postEvent( MultiEvent.SMS_SEND_FAILED_NORADIO );
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_NO_SERVICE:
|
||||
DbgUtils.showf( SMSService.this, "NO SERVICE!!!" );
|
||||
default:
|
||||
DbgUtils.logw( TAG, "FAILURE!!!" );
|
||||
sendResult( MultiEvent.SMS_SEND_FAILED );
|
||||
postEvent( MultiEvent.SMS_SEND_FAILED );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -709,7 +709,7 @@ public class WiDirService extends XWService {
|
|||
private void handleGameGone( Intent intent )
|
||||
{
|
||||
int gameID = intent.getIntExtra( KEY_GAMEID, 0 );
|
||||
sendResult( MultiEvent.MESSAGE_NOGAME, gameID );
|
||||
postEvent( MultiEvent.MESSAGE_NOGAME, gameID );
|
||||
}
|
||||
|
||||
private void makeGame( NetLaunchInfo nli, String senderMac )
|
||||
|
|
|
@ -60,12 +60,13 @@ class XWService extends Service {
|
|||
s_srcMgr.setListener( li );
|
||||
}
|
||||
|
||||
protected void sendResult( MultiEvent event, Object ... args )
|
||||
protected void postEvent( MultiEvent event, Object ... args )
|
||||
{
|
||||
if ( null != s_srcMgr ) {
|
||||
s_srcMgr.sendResult( event, args );
|
||||
s_srcMgr.postEvent( event, args );
|
||||
} else {
|
||||
DbgUtils.logd( TAG, "sendResult(): dropping %s event", event.toString() );
|
||||
DbgUtils.logd( TAG, "postEvent(): dropping %s event",
|
||||
event.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue