mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-09 22:00:39 +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;
|
boolean sourceLocal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameSummary getSummary( Context context, String file )
|
public static GameSummary getSummary( Context context, String file,
|
||||||
|
boolean wait )
|
||||||
{
|
{
|
||||||
GameSummary result = null;
|
GameSummary result = null;
|
||||||
GameUtils.GameLock lock = new GameUtils.GameLock( file, false );
|
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 );
|
result = getSummary( context, lock );
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameSummary getSummary( Context context, GameUtils.GameLock lock )
|
public static GameSummary getSummary( Context context,
|
||||||
|
GameUtils.GameLock lock )
|
||||||
{
|
{
|
||||||
initDB( context );
|
initDB( context );
|
||||||
GameSummary summary = null;
|
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
|
// If we can't read the summary right now we still need to
|
||||||
// return a view but shouldn't cache it
|
// 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 ) {
|
if ( null != summary ) {
|
||||||
TextView view;
|
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
|
// 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
|
// dialog in case it was dismissed. That way it to check for
|
||||||
// an empty room name.
|
// 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
|
if ( summary.conType == CommsAddrRec.CommsConnType.COMMS_CONN_RELAY
|
||||||
&& summary.roomName.length() == 0 ) {
|
&& summary.roomName.length() == 0 ) {
|
||||||
// If it's unconfigured and of the type RelayGameActivity
|
// If it's unconfigured and of the type RelayGameActivity
|
||||||
|
@ -420,7 +420,7 @@ public class GamesList extends XWListActivity
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.list_item_copy:
|
case R.id.list_item_copy:
|
||||||
GameSummary summary = DBUtils.getSummary( this, path );
|
GameSummary summary = DBUtils.getSummary( this, path, true );
|
||||||
if ( summary.inNetworkGame() ) {
|
if ( summary.inNetworkGame() ) {
|
||||||
showOKOnlyDialog( R.string.no_copy_network );
|
showOKOnlyDialog( R.string.no_copy_network );
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue