mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
Test whether game is on device before starting process of opening it.
Fixes problem caused by relay sending messages for games that have been deleted.
This commit is contained in:
parent
4ce2368e90
commit
64b89536b0
3 changed files with 28 additions and 5 deletions
|
@ -481,6 +481,24 @@ public class DBUtils {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean haveGame( Context context, long rowid )
|
||||||
|
{
|
||||||
|
boolean result = false;
|
||||||
|
initDB( context );
|
||||||
|
synchronized( s_dbHelper ) {
|
||||||
|
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
|
||||||
|
String[] columns = { ROW_ID };
|
||||||
|
String selection = String.format( ROW_ID + "=%d", rowid );
|
||||||
|
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
|
||||||
|
selection, null, null, null, null );
|
||||||
|
Assert.assertTrue( 1 >= cursor.getCount() );
|
||||||
|
result = 1 == cursor.getCount();
|
||||||
|
cursor.close();
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static void listBTGames( Context context,
|
public static void listBTGames( Context context,
|
||||||
HashMap<String, int[]> result )
|
HashMap<String, int[]> result )
|
||||||
{
|
{
|
||||||
|
|
|
@ -953,7 +953,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
|
|
||||||
private void startFirstHasDict( long rowid )
|
private void startFirstHasDict( long rowid )
|
||||||
{
|
{
|
||||||
if ( -1 != rowid ) {
|
if ( -1 != rowid && DBUtils.haveGame( this, rowid ) ) {
|
||||||
if ( GameUtils.gameDictsHere( this, rowid ) ) {
|
if ( GameUtils.gameDictsHere( this, rowid ) ) {
|
||||||
launchGame( rowid );
|
launchGame( rowid );
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,10 +128,15 @@ public class RelayService extends XWService {
|
||||||
{
|
{
|
||||||
DbgUtils.logf( "RelayService::postData: packet of length %d for token %d",
|
DbgUtils.logf( "RelayService::postData: packet of length %d for token %d",
|
||||||
msg.length, rowid );
|
msg.length, rowid );
|
||||||
Intent intent = getIntentTo( context, RECEIVE )
|
if ( DBUtils.haveGame( context, rowid ) ) {
|
||||||
.putExtra( ROWID, rowid )
|
Intent intent = getIntentTo( context, RECEIVE )
|
||||||
.putExtra( BINBUFFER, msg );
|
.putExtra( ROWID, rowid )
|
||||||
context.startService( intent );
|
.putExtra( BINBUFFER, msg );
|
||||||
|
context.startService( intent );
|
||||||
|
} else {
|
||||||
|
DbgUtils.logf( "RelayService.postData(): Dropping message for "
|
||||||
|
+ "rowid %d: not on device", rowid );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void udpChanged( Context context )
|
public static void udpChanged( Context context )
|
||||||
|
|
Loading…
Reference in a new issue