mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-01 06:19:57 +01:00
on launch to handle an invite for a game that seems to already exist,
instead launch that game -- for better feedback.
This commit is contained in:
parent
b244adae1b
commit
04d839868d
2 changed files with 23 additions and 7 deletions
|
@ -551,10 +551,12 @@ public class DBUtils {
|
|||
synchronized( s_dbHelper ) {
|
||||
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
|
||||
String[] columns = { ROW_ID };
|
||||
String selection = DBHelper.ROOMNAME + "='" + nli.room + "' AND "
|
||||
+ DBHelper.INVITEID + "='" + nli.inviteID + "' AND "
|
||||
+ DBHelper.DICTLANG + "=" + nli.lang + " AND "
|
||||
+ DBHelper.NUM_PLAYERS + "=" + nli.nPlayers;
|
||||
String selection =
|
||||
String.format( "%s='%s' AND %s='%s' AND %s=%d AND %s=%d",
|
||||
DBHelper.ROOMNAME, nli.room,
|
||||
DBHelper.INVITEID, nli.inviteID,
|
||||
DBHelper.DICTLANG, nli.lang,
|
||||
DBHelper.NUM_PLAYERS, nli.nPlayers );
|
||||
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
|
||||
selection, null, null, null, null );
|
||||
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
|
||||
|
@ -566,10 +568,14 @@ public class DBUtils {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static boolean isNewInvite( Context context, Uri data )
|
||||
public static long getRowIDForOpen( Context context, Uri data )
|
||||
{
|
||||
long rowid = ROWID_NOTFOUND;
|
||||
NetLaunchInfo nli = new NetLaunchInfo( data );
|
||||
return null != nli && -1 == getRowIDForOpen( context, nli );
|
||||
if ( null != nli ) {
|
||||
rowid = getRowIDForOpen( context, nli );
|
||||
}
|
||||
return rowid;
|
||||
}
|
||||
|
||||
public static String[] getRelayIDs( Context context, boolean noMsgs )
|
||||
|
|
|
@ -29,6 +29,8 @@ import android.os.Bundle;
|
|||
import java.util.HashSet;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.jni.GameSummary;
|
||||
|
||||
public class DispatchNotify extends Activity {
|
||||
|
||||
public static final String RELAYIDS_EXTRA = "relayids";
|
||||
|
@ -63,12 +65,20 @@ public class DispatchNotify extends Activity {
|
|||
mustLaunch = true;
|
||||
}
|
||||
} else if ( null != data ) {
|
||||
if ( DBUtils.isNewInvite( this, data ) ) {
|
||||
long rowid = DBUtils.getRowIDForOpen( this, data );
|
||||
if ( DBUtils.ROWID_NOTFOUND == rowid ) {
|
||||
if ( !tryHandle( data ) ) {
|
||||
mustLaunch = true;
|
||||
}
|
||||
} else {
|
||||
DbgUtils.logf( "DispatchNotify: dropping duplicate invite" );
|
||||
GameSummary summary = DBUtils.getSummary( this, rowid );
|
||||
if ( null != summary ) {
|
||||
gameID = summary.gameID;
|
||||
if ( !tryHandle( gameID ) ) {
|
||||
mustLaunch = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue