From 0e3651131e565594189bd52f57f0b50d546ea181 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 9 Aug 2020 12:17:34 -0700 Subject: [PATCH] get rid of two unnecessary classes --- .../org/eehouse/android/xw4/MQTTUtils.java | 19 ++----------------- .../org/eehouse/android/xw4/NFCUtils.java | 18 ++---------------- .../eehouse/android/xw4/XWServiceHelper.java | 6 +++++- 3 files changed, 9 insertions(+), 34 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java index 84b172cae..4d8ae4d20 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java @@ -554,7 +554,7 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba notifyNotHere( context, from.mqtt_devID, gameID ); } else { for ( long rowid : rowids ) { - MQTTMsgSink sink = new MQTTMsgSink( context, rowid ); + MultiMsgSink sink = new MultiMsgSink( context, rowid ); helper.receiveMessage( rowid, sink, data ); } } @@ -584,13 +584,6 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba mReturnAddr = from; } - @Override - protected MultiMsgSink getSink( long rowid ) - { - Context context = getContext(); - return new MQTTMsgSink( context, rowid ); - } - @Override 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 ); } - 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 ); receiveMessage( rowid, sink, msg, mReturnAddr ); } } - - private static class MQTTMsgSink extends MultiMsgSink { - MQTTMsgSink( Context context, long rowid ) - { - super( context, rowid ); - } - } - } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NFCUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NFCUtils.java index 4c2983127..20fe2d14c 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NFCUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NFCUtils.java @@ -381,7 +381,7 @@ public class NFCUtils { addReplyFor( new byte[]{REPLY_NOGAME}, gameID[0] ); } else { for ( long rowid : rowids ) { - NFCMsgSink sink = new NFCMsgSink( context, rowid ); + MultiMsgSink sink = new MultiMsgSink( context, rowid ); helper.receiveMessage( rowid, sink, body ); } } @@ -1042,13 +1042,6 @@ public class NFCUtils { super( context ); } - @Override - protected MultiMsgSink getSink( long rowid ) - { - Context context = getContext(); - return new NFCMsgSink( context, rowid ); - } - @Override void postNotification( String device, int gameID, long rowid ) { @@ -1057,17 +1050,10 @@ public class NFCUtils { 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 ); receiveMessage( rowid, sink, msg, mAddr ); } } - - private static class NFCMsgSink extends MultiMsgSink { - NFCMsgSink( Context context, long rowid ) - { - super( context, rowid ); - } - } } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWServiceHelper.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWServiceHelper.java index 90d070d6c..169718497 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWServiceHelper.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWServiceHelper.java @@ -50,7 +50,11 @@ abstract class XWServiceHelper { 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 ); protected ReceiveResult receiveMessage( int gameID,