From ec3168e27d02c6baefd178ca6a7f4f394ae1a8aa Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 29 Aug 2014 07:00:27 -0700 Subject: [PATCH] fix, I hope, the occasional misssing notification body by handling the case where multiple move messages are handled at once. --- .../org/eehouse/android/xw4/RelayService.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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 f3a20bd22..7fab68910 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java @@ -366,13 +366,15 @@ public class RelayService extends XWService startService( this ); // bad name: will *stop* threads too } - private void setupNotifications( String[] relayIDs ) + private void setupNotifications( String[] relayIDs, LastMoveInfo[] lmis ) { - for ( String relayID : relayIDs ) { + for ( int ii = 0; ii < relayIDs.length; ++ii ) { + String relayID = relayIDs[ii]; + LastMoveInfo lmi = lmis[ii]; long[] rowids = DBUtils.getRowIDsFor( this, relayID ); if ( null != rowids ) { for ( long rowid : rowids ) { - setupNotification( rowid, null ); + setupNotification( rowid, lmi ); } } } @@ -893,18 +895,21 @@ public class RelayService extends XWService int nameCount = relayIDs.length; DbgUtils.logf( "RelayService.process(): nameCount: %d", nameCount ); ArrayList idsWMsgs = new ArrayList( nameCount ); + ArrayList lmis = new ArrayList( nameCount ); for ( int ii = 0; ii < nameCount; ++ii ) { byte[][] forOne = msgs[ii]; // if game has messages, open it and feed 'em to it. if ( null != forOne ) { + LastMoveInfo lmi = new LastMoveInfo(); sink.setRowID( rowIDs[ii] ); if ( BoardDelegate.feedMessages( rowIDs[ii], forOne ) || GameUtils.feedMessages( this, rowIDs[ii], forOne, null, - sink, null ) ) { + sink, lmi ) ) { idsWMsgs.add( relayIDs[ii] ); + lmis.add( lmi ); } else { DbgUtils.logf( "message for %s (rowid %d) not consumed", relayIDs[ii], rowIDs[ii] ); @@ -914,7 +919,9 @@ public class RelayService extends XWService if ( 0 < idsWMsgs.size() ) { String[] tmp = new String[idsWMsgs.size()]; idsWMsgs.toArray( tmp ); - setupNotifications( tmp ); + LastMoveInfo[] lmisa = new LastMoveInfo[lmis.size()]; + lmis.toArray( lmisa ); + setupNotifications( tmp, lmisa ); } sink.send( this ); }