mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-14 08:01:38 +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()" );
|
Utils.logf( "BoardActivity::onPause()" );
|
||||||
if ( null != m_jniThread ) {
|
if ( null != m_jniThread ) {
|
||||||
m_jniThread.handle( JNIThread.JNICmd.CMD_SAVE );
|
m_jniThread.setInBackground( true );
|
||||||
}
|
}
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
@ -283,6 +283,9 @@ public class BoardActivity extends Activity implements UtilCtxt {
|
||||||
protected void onResume()
|
protected void onResume()
|
||||||
{
|
{
|
||||||
Utils.logf( "BoardActivity::onResume()" );
|
Utils.logf( "BoardActivity::onResume()" );
|
||||||
|
if ( null != m_jniThread ) {
|
||||||
|
m_jniThread.setInBackground( false );
|
||||||
|
}
|
||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,7 @@ public class JNIThread extends Thread {
|
||||||
private boolean m_keyDown = false;
|
private boolean m_keyDown = false;
|
||||||
private Rect m_connsIconRect;
|
private Rect m_connsIconRect;
|
||||||
private int m_connsIconID = 0;
|
private int m_connsIconID = 0;
|
||||||
|
private boolean m_inBack = false;
|
||||||
|
|
||||||
LinkedBlockingQueue<QueueElem> m_queue;
|
LinkedBlockingQueue<QueueElem> m_queue;
|
||||||
|
|
||||||
|
@ -133,6 +134,14 @@ public class JNIThread extends Thread {
|
||||||
return siz > 0;
|
return siz > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setInBackground( boolean inBack )
|
||||||
|
{
|
||||||
|
m_inBack = inBack;
|
||||||
|
if ( inBack ) {
|
||||||
|
handle( JNICmd.CMD_SAVE );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean toggleTray() {
|
private boolean toggleTray() {
|
||||||
boolean draw;
|
boolean draw;
|
||||||
int state = XwJNI.board_getTrayVisState( m_jniGamePtr );
|
int state = XwJNI.board_getTrayVisState( m_jniGamePtr );
|
||||||
|
@ -261,6 +270,9 @@ public class JNIThread extends Thread {
|
||||||
switch( elem.m_cmd ) {
|
switch( elem.m_cmd ) {
|
||||||
|
|
||||||
case CMD_SAVE:
|
case CMD_SAVE:
|
||||||
|
if ( nextSame( JNICmd.CMD_SAVE ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
GameSummary summary = new GameSummary();
|
GameSummary summary = new GameSummary();
|
||||||
XwJNI.game_summarize( m_jniGamePtr, m_gi.nPlayers, summary );
|
XwJNI.game_summarize( m_jniGamePtr, m_gi.nPlayers, summary );
|
||||||
byte[] state = XwJNI.game_saveToStream( m_jniGamePtr, null );
|
byte[] state = XwJNI.game_saveToStream( m_jniGamePtr, null );
|
||||||
|
@ -300,6 +312,9 @@ public class JNIThread extends Thread {
|
||||||
draw = XwJNI.game_receiveMessage( m_jniGamePtr,
|
draw = XwJNI.game_receiveMessage( m_jniGamePtr,
|
||||||
(byte[])args[0] );
|
(byte[])args[0] );
|
||||||
handle( JNICmd.CMD_DO );
|
handle( JNICmd.CMD_DO );
|
||||||
|
if ( m_inBack ) {
|
||||||
|
handle( JNICmd.CMD_SAVE );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_TRANSFAIL:
|
case CMD_TRANSFAIL:
|
||||||
|
|
Loading…
Reference in a new issue