mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
preexisting db field now a set, so treat it that way in the other place it's read
This commit is contained in:
parent
4e37947d94
commit
df093e1c10
2 changed files with 20 additions and 9 deletions
|
@ -522,10 +522,10 @@ public class DBUtils {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static HashMap<Long,CommsConnType>
|
||||
public static HashMap<Long,CommsConnTypeSet>
|
||||
getGamesWithSendsPending( Context context )
|
||||
{
|
||||
HashMap<Long, CommsConnType> result = new HashMap<Long,CommsConnType>();
|
||||
HashMap<Long, CommsConnTypeSet> result = new HashMap<Long,CommsConnTypeSet>();
|
||||
String[] columns = { ROW_ID, DBHelper.CONTYPE };
|
||||
String selection = String.format( "%s > 0", DBHelper.NPACKETSPENDING );
|
||||
initDB( context );
|
||||
|
@ -537,8 +537,10 @@ public class DBUtils {
|
|||
int indx2 = cursor.getColumnIndex( DBHelper.CONTYPE );
|
||||
for ( int ii = 0; cursor.moveToNext(); ++ii ) {
|
||||
long rowid = cursor.getLong( indx1 );
|
||||
CommsConnType typ = CommsConnType.values()[cursor.getInt(indx2)];
|
||||
result.put( rowid, typ );
|
||||
CommsConnTypeSet typs = intToConnTypeSet( cursor.getInt(indx2) );
|
||||
// Better have an address if has pending sends
|
||||
Assert.assertTrue( 0 < typs.size() );
|
||||
result.put( rowid, typs );
|
||||
}
|
||||
cursor.close();
|
||||
db.close();
|
||||
|
@ -2134,6 +2136,7 @@ public class DBUtils {
|
|||
private static final int BIT_VECTOR_MASK = 0x8000;
|
||||
private static CommsConnTypeSet intToConnTypeSet( int asInt )
|
||||
{
|
||||
DbgUtils.logf( "intToConnTypeSet(in: %s)", asInt );
|
||||
CommsConnTypeSet result = new CommsConnTypeSet();
|
||||
boolean isVector = 0 != (BIT_VECTOR_MASK & asInt);
|
||||
asInt &= ~BIT_VECTOR_MASK;
|
||||
|
@ -2142,6 +2145,7 @@ public class DBUtils {
|
|||
for ( CommsConnType value : values ) {
|
||||
int ord = value.ordinal();
|
||||
if ( 0 != (asInt & (1 << (ord - 1)))) {
|
||||
DbgUtils.logf( "intToConnTypeSet: adding %s", value.toString() );
|
||||
result.add( value );
|
||||
}
|
||||
}
|
||||
|
@ -2153,9 +2157,11 @@ public class DBUtils {
|
|||
|
||||
private static int connTypeSetToInt( CommsConnTypeSet set )
|
||||
{
|
||||
DbgUtils.logf( "connTypeSetToInt(setSize: %d)", set.size() );
|
||||
int result = BIT_VECTOR_MASK;
|
||||
for ( Iterator<CommsConnType> iter = set.iterator(); iter.hasNext(); ) {
|
||||
CommsConnType typ = iter.next();
|
||||
DbgUtils.logf( "connTypeSetToInt: adding %s", typ.toString() );
|
||||
result |= 1 << (typ.ordinal() - 1);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -46,6 +46,7 @@ import junit.framework.Assert;
|
|||
import org.eehouse.android.xw4.jni.*;
|
||||
import org.eehouse.android.xw4.loc.LocUtils;
|
||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
|
||||
import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
|
||||
import org.eehouse.android.xw4.jni.LastMoveInfo;
|
||||
|
||||
|
@ -391,7 +392,8 @@ public class GameUtils {
|
|||
}
|
||||
|
||||
if ( force ) {
|
||||
HashMap<Long,CommsConnType> games = DBUtils.getGamesWithSendsPending( context );
|
||||
HashMap<Long,CommsConnTypeSet> games =
|
||||
DBUtils.getGamesWithSendsPending( context );
|
||||
if ( 0 < games.size() ) {
|
||||
new ResendTask( context, games, filter, showUI ).execute();
|
||||
}
|
||||
|
@ -1076,12 +1078,12 @@ public class GameUtils {
|
|||
|
||||
private static class ResendTask extends AsyncTask<Void, Void, Void> {
|
||||
private Context m_context;
|
||||
private HashMap<Long,CommsConnType> m_games;
|
||||
private HashMap<Long,CommsConnTypeSet> m_games;
|
||||
private boolean m_showUI;
|
||||
private CommsConnType m_filter;
|
||||
private int m_nSent = 0;
|
||||
|
||||
public ResendTask( Context context, HashMap<Long,CommsConnType> games,
|
||||
public ResendTask( Context context, HashMap<Long,CommsConnTypeSet> games,
|
||||
CommsConnType filter, boolean showUI )
|
||||
{
|
||||
m_context = context;
|
||||
|
@ -1096,8 +1098,11 @@ public class GameUtils {
|
|||
Iterator<Long> iter = m_games.keySet().iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
long rowid = iter.next();
|
||||
if ( null != m_filter && m_filter != m_games.get( rowid ) ) {
|
||||
continue;
|
||||
if ( null != m_filter ) {
|
||||
CommsConnTypeSet gameSet = m_games.get( rowid );
|
||||
if ( gameSet != null && ! gameSet.contains( m_filter ) ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
GameLock lock = new GameLock( rowid, false );
|
||||
|
|
Loading…
Reference in a new issue