mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
add connType param to resendAllIf(): no point resending relay messages
when it's the BT radio that just turned on.
This commit is contained in:
parent
645da39e51
commit
ff82ff1e7c
4 changed files with 22 additions and 6 deletions
|
@ -324,7 +324,8 @@ public class BTService extends XWService {
|
|||
: MultiEvent.BT_DISABLED;
|
||||
sendResult( evt );
|
||||
if ( cameOn ) {
|
||||
GameUtils.resendAllIf( this, false );
|
||||
GameUtils.resendAllIf( this, CommsConnType.COMMS_CONN_BT,
|
||||
false );
|
||||
} else {
|
||||
ConnStatusHandler.updateStatus( this, null,
|
||||
CommsConnType.COMMS_CONN_BT,
|
||||
|
|
|
@ -374,7 +374,8 @@ public class GameUtils {
|
|||
return thumb;
|
||||
}
|
||||
|
||||
public static void resendAllIf( Context context, boolean force )
|
||||
public static void resendAllIf( Context context, CommsConnType filter,
|
||||
boolean force )
|
||||
{
|
||||
final boolean showUI = force;
|
||||
|
||||
|
@ -393,7 +394,7 @@ public class GameUtils {
|
|||
if ( force ) {
|
||||
HashMap<Long,CommsConnType> games = DBUtils.getGamesWithSendsPending( context );
|
||||
if ( 0 < games.size() ) {
|
||||
new ResendTask( context, games, showUI ).execute();
|
||||
new ResendTask( context, games, filter, showUI ).execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1075,13 +1076,15 @@ public class GameUtils {
|
|||
private Context m_context;
|
||||
private HashMap<Long,CommsConnType> m_games;
|
||||
private boolean m_showUI;
|
||||
private CommsConnType m_filter;
|
||||
private int m_nSent = 0;
|
||||
|
||||
public ResendTask( Context context, HashMap<Long,CommsConnType> games,
|
||||
boolean showUI )
|
||||
CommsConnType filter, boolean showUI )
|
||||
{
|
||||
m_context = context;
|
||||
m_games = games;
|
||||
m_filter = filter;
|
||||
m_showUI = showUI;
|
||||
}
|
||||
|
||||
|
@ -1091,6 +1094,10 @@ 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;
|
||||
}
|
||||
|
||||
GameLock lock = new GameLock( rowid, false );
|
||||
if ( lock.tryLock() ) {
|
||||
CurGameInfo gi = new CurGameInfo( m_context );
|
||||
|
@ -1100,6 +1107,9 @@ public class GameUtils {
|
|||
XwJNI.comms_resendAll( gamePtr, true, false );
|
||||
}
|
||||
lock.unlock();
|
||||
} else {
|
||||
DbgUtils.logf( "ResendTask.doInBackground: unable to unlock %d",
|
||||
rowid );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1156,7 +1156,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
switch ( itemID ) {
|
||||
// There's no selection for these items, so nothing to clear
|
||||
case R.id.games_menu_resend:
|
||||
GameUtils.resendAllIf( m_activity, true );
|
||||
GameUtils.resendAllIf( m_activity, null, true );
|
||||
break;
|
||||
case R.id.games_menu_newgame:
|
||||
startNewGameActivity( groupID );
|
||||
|
|
|
@ -33,6 +33,8 @@ import java.util.Iterator;
|
|||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||
|
||||
public class NetStateCache {
|
||||
private static final long WAIT_STABLE_MILLIS = 2 * 1000;
|
||||
|
||||
|
@ -160,7 +162,10 @@ public class NetStateCache {
|
|||
}
|
||||
|
||||
if ( s_netAvail ) {
|
||||
GameUtils.resendAllIf( context, false );
|
||||
CommsConnType typ = CommsConnType
|
||||
.COMMS_CONN_RELAY;
|
||||
GameUtils.resendAllIf( context, typ,
|
||||
false );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue