mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
toward having networking and activity swaps work without fully
shutting down the game in onPause(): use pause() and resume() to suspend the jnithread when the game's been unlocked.
This commit is contained in:
parent
7c45e3c5b3
commit
a72932486b
1 changed files with 25 additions and 9 deletions
|
@ -191,7 +191,6 @@ public class BoardActivity extends XWActivity
|
|||
if ( 1 == s_this.size() ) {
|
||||
BoardActivity self = s_this.iterator().next();
|
||||
Assert.assertNotNull( self.m_gi );
|
||||
Assert.assertNotNull( self.m_gameLock );
|
||||
Assert.assertNotNull( self.m_jniThread );
|
||||
if ( gameID == self.m_gi.gameID ) {
|
||||
self.m_jniThread.handle( JNICmd.CMD_RECEIVE, msg, retAddr );
|
||||
|
@ -215,7 +214,6 @@ public class BoardActivity extends XWActivity
|
|||
if ( 1 == s_this.size() ) {
|
||||
BoardActivity self = s_this.iterator().next();
|
||||
Assert.assertNotNull( self.m_gi );
|
||||
Assert.assertNotNull( self.m_gameLock );
|
||||
Assert.assertNotNull( self.m_jniThread );
|
||||
if ( rowid == self.m_rowid ) {
|
||||
delivered = true; // even if no messages!
|
||||
|
@ -586,7 +584,11 @@ public class BoardActivity extends XWActivity
|
|||
m_handler = null;
|
||||
ConnStatusHandler.setHandler( null );
|
||||
waitCloseGame( true );
|
||||
} else if ( null != m_jniThread ) {
|
||||
m_jniThread.pause();
|
||||
}
|
||||
unlockGameIf();
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
@ -594,6 +596,8 @@ public class BoardActivity extends XWActivity
|
|||
protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
|
||||
lockGame();
|
||||
if ( null == m_handler ) {
|
||||
m_handler = new Handler();
|
||||
m_blockingDlgID = BLOCKING_DLG_NONE;
|
||||
|
@ -603,6 +607,8 @@ public class BoardActivity extends XWActivity
|
|||
loadGame();
|
||||
|
||||
ConnStatusHandler.setHandler( this );
|
||||
} else {
|
||||
m_jniThread.resume( m_gameLock );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1247,6 +1253,20 @@ public class BoardActivity extends XWActivity
|
|||
return m_handler;
|
||||
}
|
||||
|
||||
private void unlockGameIf()
|
||||
{
|
||||
if ( null != m_gameLock ) {
|
||||
m_gameLock.unlock();
|
||||
m_gameLock = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void lockGame()
|
||||
{
|
||||
Assert.assertNull( m_gameLock );
|
||||
m_gameLock = new GameLock( m_rowid, true ).lock();
|
||||
}
|
||||
|
||||
private void setGotGameDict( String getDict )
|
||||
{
|
||||
m_jniThread.setSaveDict( getDict );
|
||||
|
@ -1813,15 +1833,13 @@ public class BoardActivity extends XWActivity
|
|||
{
|
||||
if ( 0 == m_jniGamePtr ) {
|
||||
try {
|
||||
String[] dictNames = GameUtils.dictNames( this, m_rowid );
|
||||
String[] dictNames = GameUtils.dictNames( this, m_gameLock );
|
||||
DictUtils.DictPairs pairs = DictUtils.openDicts( this, dictNames );
|
||||
|
||||
if ( pairs.anyMissing( dictNames ) ) {
|
||||
// TEST THIS CASE!!!
|
||||
showDictGoneFinish();
|
||||
} else {
|
||||
Assert.assertNull( m_gameLock );
|
||||
m_gameLock = new GameLock( m_rowid, true ).lock();
|
||||
|
||||
byte[] stream = GameUtils.savedGame( this, m_gameLock );
|
||||
m_gi = new CurGameInfo( this );
|
||||
XwJNI.gi_from_stream( m_gi, stream );
|
||||
|
@ -2118,10 +2136,8 @@ public class BoardActivity extends XWActivity
|
|||
XwJNI.game_dispose( m_jniGamePtr );
|
||||
m_jniGamePtr = 0;
|
||||
m_gi = null;
|
||||
|
||||
m_gameLock.unlock();
|
||||
m_gameLock = null;
|
||||
}
|
||||
unlockGameIf();
|
||||
}
|
||||
|
||||
private void warnIfNoTransport()
|
||||
|
|
Loading…
Reference in a new issue