From 9c14e0e858f47967b637ee480a864d01243c9b94 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 5 Dec 2016 07:24:25 -0800 Subject: [PATCH] rename method: sendResult -> postEvent --- .../org/eehouse/android/xw4/BTService.java | 30 +++++++++---------- .../org/eehouse/android/xw4/MultiService.java | 3 +- .../org/eehouse/android/xw4/RelayService.java | 2 +- .../org/eehouse/android/xw4/SMSService.java | 14 ++++----- .../org/eehouse/android/xw4/WiDirService.java | 2 +- .../org/eehouse/android/xw4/XWService.java | 7 +++-- 6 files changed, 30 insertions(+), 28 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java index 6ec29984d..5c8180e84 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java @@ -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 ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MultiService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MultiService.java index 944ede665..29abbf2c2 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MultiService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MultiService.java @@ -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 ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java index 4f6fa9763..021ca48bb 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java @@ -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 ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java index c0a6abf55..953e8bf7d 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java @@ -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; } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/WiDirService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/WiDirService.java index 0e8bb86c9..793329965 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/WiDirService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/WiDirService.java @@ -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 ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWService.java index fa4a28c86..28f3abb94 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWService.java @@ -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() ); } }