mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
add boolean 'wait' to getSummary() allowing it to return null if it
can't get a read lock. Fix GameListAdapter to handle that null.
This commit is contained in:
parent
abdabd9c3c
commit
754d7b06ef
3 changed files with 11 additions and 6 deletions
|
@ -64,18 +64,23 @@ public class DBUtils {
|
|||
boolean sourceLocal;
|
||||
}
|
||||
|
||||
public static GameSummary getSummary( Context context, String file )
|
||||
public static GameSummary getSummary( Context context, String file,
|
||||
boolean wait )
|
||||
{
|
||||
GameSummary result = null;
|
||||
GameUtils.GameLock lock = new GameUtils.GameLock( file, false );
|
||||
if ( lock.tryLock() ) {
|
||||
if ( wait ) {
|
||||
result = getSummary( context, lock.lock() );
|
||||
lock.unlock();
|
||||
} else if ( lock.tryLock() ) {
|
||||
result = getSummary( context, lock );
|
||||
lock.unlock();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static GameSummary getSummary( Context context, GameUtils.GameLock lock )
|
||||
public static GameSummary getSummary( Context context,
|
||||
GameUtils.GameLock lock )
|
||||
{
|
||||
initDB( context );
|
||||
GameSummary summary = null;
|
||||
|
|
|
@ -76,7 +76,7 @@ public class GameListAdapter extends XWListAdapter {
|
|||
|
||||
// If we can't read the summary right now we still need to
|
||||
// return a view but shouldn't cache it
|
||||
GameSummary summary = DBUtils.getSummary( m_context, path );
|
||||
GameSummary summary = DBUtils.getSummary( m_context, path, false );
|
||||
if ( null != summary ) {
|
||||
TextView view;
|
||||
|
||||
|
|
|
@ -364,7 +364,7 @@ public class GamesList extends XWListActivity
|
|||
// We need a way to let the user get back to the basic-config
|
||||
// dialog in case it was dismissed. That way it to check for
|
||||
// an empty room name.
|
||||
GameSummary summary = DBUtils.getSummary( this, path );
|
||||
GameSummary summary = DBUtils.getSummary( this, path, true );
|
||||
if ( summary.conType == CommsAddrRec.CommsConnType.COMMS_CONN_RELAY
|
||||
&& summary.roomName.length() == 0 ) {
|
||||
// If it's unconfigured and of the type RelayGameActivity
|
||||
|
@ -420,7 +420,7 @@ public class GamesList extends XWListActivity
|
|||
break;
|
||||
|
||||
case R.id.list_item_copy:
|
||||
GameSummary summary = DBUtils.getSummary( this, path );
|
||||
GameSummary summary = DBUtils.getSummary( this, path, true );
|
||||
if ( summary.inNetworkGame() ) {
|
||||
showOKOnlyDialog( R.string.no_copy_network );
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue