mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-13 08:01:33 +01:00
save after every network event when running in background
This commit is contained in:
parent
e1d956ac09
commit
33a1efd725
2 changed files with 19 additions and 1 deletions
|
@ -274,7 +274,7 @@ public class BoardActivity extends Activity implements UtilCtxt {
|
|||
{
|
||||
Utils.logf( "BoardActivity::onPause()" );
|
||||
if ( null != m_jniThread ) {
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_SAVE );
|
||||
m_jniThread.setInBackground( true );
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
@ -283,6 +283,9 @@ public class BoardActivity extends Activity implements UtilCtxt {
|
|||
protected void onResume()
|
||||
{
|
||||
Utils.logf( "BoardActivity::onResume()" );
|
||||
if ( null != m_jniThread ) {
|
||||
m_jniThread.setInBackground( false );
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ public class JNIThread extends Thread {
|
|||
private boolean m_keyDown = false;
|
||||
private Rect m_connsIconRect;
|
||||
private int m_connsIconID = 0;
|
||||
private boolean m_inBack = false;
|
||||
|
||||
LinkedBlockingQueue<QueueElem> m_queue;
|
||||
|
||||
|
@ -133,6 +134,14 @@ public class JNIThread extends Thread {
|
|||
return siz > 0;
|
||||
}
|
||||
|
||||
public void setInBackground( boolean inBack )
|
||||
{
|
||||
m_inBack = inBack;
|
||||
if ( inBack ) {
|
||||
handle( JNICmd.CMD_SAVE );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean toggleTray() {
|
||||
boolean draw;
|
||||
int state = XwJNI.board_getTrayVisState( m_jniGamePtr );
|
||||
|
@ -261,6 +270,9 @@ public class JNIThread extends Thread {
|
|||
switch( elem.m_cmd ) {
|
||||
|
||||
case CMD_SAVE:
|
||||
if ( nextSame( JNICmd.CMD_SAVE ) ) {
|
||||
continue;
|
||||
}
|
||||
GameSummary summary = new GameSummary();
|
||||
XwJNI.game_summarize( m_jniGamePtr, m_gi.nPlayers, summary );
|
||||
byte[] state = XwJNI.game_saveToStream( m_jniGamePtr, null );
|
||||
|
@ -300,6 +312,9 @@ public class JNIThread extends Thread {
|
|||
draw = XwJNI.game_receiveMessage( m_jniGamePtr,
|
||||
(byte[])args[0] );
|
||||
handle( JNICmd.CMD_DO );
|
||||
if ( m_inBack ) {
|
||||
handle( JNICmd.CMD_SAVE );
|
||||
}
|
||||
break;
|
||||
|
||||
case CMD_TRANSFAIL:
|
||||
|
|
Loading…
Reference in a new issue