mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-06 05:24:46 +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 ) {
|
synchronized( s_dbHelper ) {
|
||||||
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
|
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
|
||||||
String[] columns = { ROW_ID };
|
String[] columns = { ROW_ID };
|
||||||
String selection = DBHelper.ROOMNAME + "='" + nli.room + "' AND "
|
String selection =
|
||||||
+ DBHelper.INVITEID + "='" + nli.inviteID + "' AND "
|
String.format( "%s='%s' AND %s='%s' AND %s=%d AND %s=%d",
|
||||||
+ DBHelper.DICTLANG + "=" + nli.lang + " AND "
|
DBHelper.ROOMNAME, nli.room,
|
||||||
+ DBHelper.NUM_PLAYERS + "=" + nli.nPlayers;
|
DBHelper.INVITEID, nli.inviteID,
|
||||||
|
DBHelper.DICTLANG, nli.lang,
|
||||||
|
DBHelper.NUM_PLAYERS, nli.nPlayers );
|
||||||
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
|
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
|
||||||
selection, null, null, null, null );
|
selection, null, null, null, null );
|
||||||
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
|
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
|
||||||
|
@ -566,10 +568,14 @@ public class DBUtils {
|
||||||
return result;
|
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 );
|
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 )
|
public static String[] getRelayIDs( Context context, boolean noMsgs )
|
||||||
|
|
|
@ -29,6 +29,8 @@ import android.os.Bundle;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.jni.GameSummary;
|
||||||
|
|
||||||
public class DispatchNotify extends Activity {
|
public class DispatchNotify extends Activity {
|
||||||
|
|
||||||
public static final String RELAYIDS_EXTRA = "relayids";
|
public static final String RELAYIDS_EXTRA = "relayids";
|
||||||
|
@ -63,12 +65,20 @@ public class DispatchNotify extends Activity {
|
||||||
mustLaunch = true;
|
mustLaunch = true;
|
||||||
}
|
}
|
||||||
} else if ( null != data ) {
|
} else if ( null != data ) {
|
||||||
if ( DBUtils.isNewInvite( this, data ) ) {
|
long rowid = DBUtils.getRowIDForOpen( this, data );
|
||||||
|
if ( DBUtils.ROWID_NOTFOUND == rowid ) {
|
||||||
if ( !tryHandle( data ) ) {
|
if ( !tryHandle( data ) ) {
|
||||||
mustLaunch = true;
|
mustLaunch = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DbgUtils.logf( "DispatchNotify: dropping duplicate invite" );
|
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