mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
set check-relay timer when saving a game with a relay connection
This commit is contained in:
parent
38b958751c
commit
60509f7c8b
2 changed files with 12 additions and 4 deletions
|
@ -280,6 +280,7 @@ public class DBUtils {
|
|||
public static void saveSummary( Context context, GameLock lock,
|
||||
GameSummary summary, String inviteID )
|
||||
{
|
||||
boolean needsTimer = false;
|
||||
Assert.assertTrue( lock.canWrite() );
|
||||
long rowid = lock.getRowid();
|
||||
String selection = String.format( ROW_ID_FMT, rowid );
|
||||
|
@ -328,7 +329,9 @@ public class DBUtils {
|
|||
switch ( iter.next() ) {
|
||||
case COMMS_CONN_RELAY:
|
||||
values.put( DBHelper.ROOMNAME, summary.roomName );
|
||||
values.put( DBHelper.RELAYID, summary.relayID );
|
||||
String relayID = summary.relayID;
|
||||
values.put( DBHelper.RELAYID, relayID );
|
||||
needsTimer = null != relayID && 0 < relayID.length();
|
||||
break;
|
||||
case COMMS_CONN_BT:
|
||||
case COMMS_CONN_SMS:
|
||||
|
@ -361,6 +364,10 @@ public class DBUtils {
|
|||
if ( null != summary ) { // nag time may have changed
|
||||
NagTurnReceiver.setNagTimer( context );
|
||||
}
|
||||
|
||||
if ( needsTimer ) {
|
||||
RelayReceiver.setTimer( context );
|
||||
}
|
||||
} // saveSummary
|
||||
|
||||
public static void addRematchInfo( Context context, long rowid, String btAddr,
|
||||
|
@ -751,7 +758,7 @@ public class DBUtils {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static boolean haveRelayGames( Context context )
|
||||
public static boolean haveRelayIDs( Context context )
|
||||
{
|
||||
long[][] rowIDss = new long[1][];
|
||||
String[] relayIDs = getRelayIDs( context, rowIDss );
|
||||
|
|
|
@ -50,8 +50,9 @@ public class RelayReceiver extends BroadcastReceiver {
|
|||
Intent intent = new Intent( context, RelayReceiver.class );
|
||||
PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, 0 );
|
||||
|
||||
// Check if we have any relay games
|
||||
if ( interval_millis > 0 && DBUtils.haveRelayGames( context ) ) {
|
||||
// Check if we have any relay IDs, since we'll be using them to
|
||||
// identify connected games for which we can fetch messages
|
||||
if ( interval_millis > 0 && DBUtils.haveRelayIDs( context ) ) {
|
||||
long fire_millis = SystemClock.elapsedRealtime() + interval_millis;
|
||||
am.set( AlarmManager.ELAPSED_REALTIME_WAKEUP, fire_millis, pi );
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue