From f6a91464ac8e5f983fda938efa942d0156dc43e4 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 31 Aug 2013 07:50:30 -0700 Subject: [PATCH] don't update db unless value's changed --- .../src/org/eehouse/android/xw4/RelayService.java | 14 +++++++++----- 1 file changed, 9 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 9cf9c1219..3390243e0 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java @@ -552,14 +552,18 @@ public class RelayService extends XWService requestMessages(); break; case XWPDEV_MSG: - // game-related packets only count - m_lastGamePacketReceived = Utils.getCurSeconds(); - XWPrefs.setPrefsLong( this, R.string.key_last_packet, - m_lastGamePacketReceived ); int token = dis.readInt(); byte[] msg = new byte[dis.available()]; dis.read( msg ); - postData( RelayService.this, token, msg ); + postData( this, token, msg ); + + // game-related packets only count + long lastGamePacketReceived = Utils.getCurSeconds(); + if ( lastGamePacketReceived != m_lastGamePacketReceived ) { + XWPrefs.setPrefsLong( this, R.string.key_last_packet, + lastGamePacketReceived ); + m_lastGamePacketReceived = lastGamePacketReceived; + } break; case XWPDEV_ACK: noteAck( vli2un( dis ) );