get rid of two unnecessary classes

This commit is contained in:
Eric House 2020-08-09 12:17:34 -07:00
parent 0b9f628115
commit 0e3651131e
3 changed files with 9 additions and 34 deletions

View file

@ -554,7 +554,7 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba
notifyNotHere( context, from.mqtt_devID, gameID ); notifyNotHere( context, from.mqtt_devID, gameID );
} else { } else {
for ( long rowid : rowids ) { for ( long rowid : rowids ) {
MQTTMsgSink sink = new MQTTMsgSink( context, rowid ); MultiMsgSink sink = new MultiMsgSink( context, rowid );
helper.receiveMessage( rowid, sink, data ); helper.receiveMessage( rowid, sink, data );
} }
} }
@ -584,13 +584,6 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba
mReturnAddr = from; mReturnAddr = from;
} }
@Override
protected MultiMsgSink getSink( long rowid )
{
Context context = getContext();
return new MQTTMsgSink( context, rowid );
}
@Override @Override
void postNotification( String device, int gameID, long rowid ) void postNotification( String device, int gameID, long rowid )
{ {
@ -600,18 +593,10 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba
// GameUtils.postInvitedNotification( mContext, gameID, body, rowid ); // GameUtils.postInvitedNotification( mContext, gameID, body, rowid );
} }
private void receiveMessage( long rowid, MQTTMsgSink sink, byte[] msg ) private void receiveMessage( long rowid, MultiMsgSink sink, byte[] msg )
{ {
Log.d( TAG, "receiveMessage(rowid=%d, len=%d)", rowid, msg.length ); Log.d( TAG, "receiveMessage(rowid=%d, len=%d)", rowid, msg.length );
receiveMessage( rowid, sink, msg, mReturnAddr ); receiveMessage( rowid, sink, msg, mReturnAddr );
} }
} }
private static class MQTTMsgSink extends MultiMsgSink {
MQTTMsgSink( Context context, long rowid )
{
super( context, rowid );
}
}
} }

View file

@ -381,7 +381,7 @@ public class NFCUtils {
addReplyFor( new byte[]{REPLY_NOGAME}, gameID[0] ); addReplyFor( new byte[]{REPLY_NOGAME}, gameID[0] );
} else { } else {
for ( long rowid : rowids ) { for ( long rowid : rowids ) {
NFCMsgSink sink = new NFCMsgSink( context, rowid ); MultiMsgSink sink = new MultiMsgSink( context, rowid );
helper.receiveMessage( rowid, sink, body ); helper.receiveMessage( rowid, sink, body );
} }
} }
@ -1042,13 +1042,6 @@ public class NFCUtils {
super( context ); super( context );
} }
@Override
protected MultiMsgSink getSink( long rowid )
{
Context context = getContext();
return new NFCMsgSink( context, rowid );
}
@Override @Override
void postNotification( String device, int gameID, long rowid ) void postNotification( String device, int gameID, long rowid )
{ {
@ -1057,17 +1050,10 @@ public class NFCUtils {
GameUtils.postInvitedNotification( context, gameID, body, rowid ); GameUtils.postInvitedNotification( context, gameID, body, rowid );
} }
private void receiveMessage( long rowid, NFCMsgSink sink, byte[] msg ) private void receiveMessage( long rowid, MultiMsgSink sink, byte[] msg )
{ {
Log.d( TAG, "receiveMessage(rowid=%d, len=%d)", rowid, msg.length ); Log.d( TAG, "receiveMessage(rowid=%d, len=%d)", rowid, msg.length );
receiveMessage( rowid, sink, msg, mAddr ); receiveMessage( rowid, sink, msg, mAddr );
} }
} }
private static class NFCMsgSink extends MultiMsgSink {
NFCMsgSink( Context context, long rowid )
{
super( context, rowid );
}
}
} }

View file

@ -50,7 +50,11 @@ abstract class XWServiceHelper {
Context getContext() { return mContext; } Context getContext() { return mContext; }
abstract MultiMsgSink getSink( long rowid ); MultiMsgSink getSink( long rowid )
{
return new MultiMsgSink( getContext(), rowid );
}
abstract void postNotification( String device, int gameID, long rowid ); abstract void postNotification( String device, int gameID, long rowid );
protected ReceiveResult receiveMessage( int gameID, protected ReceiveResult receiveMessage( int gameID,