fix crash: rather than pass chat message to jnithread that will be

null when the board activity has lost focus, save it to be sent once
the thread's been recreated.
This commit is contained in:
Andy2 2011-03-04 05:45:29 -08:00
parent eb3b83ec48
commit 6acf7fda68

View file

@ -33,6 +33,8 @@ import android.os.Handler;
import android.os.Message;
import android.content.Intent;
import java.util.concurrent.Semaphore;
import java.util.ArrayList;
import java.util.Iterator;
import android.net.Uri;
import android.app.Dialog;
import android.app.AlertDialog;
@ -77,6 +79,7 @@ public class BoardActivity extends XWActivity
private Uri m_uri;
private int m_currentOrient;
private Toolbar m_toolbar;
private ArrayList<String> m_pendingChats = new ArrayList<String>();
private String m_dlgBytes = null;
private EditText m_passwdEdit = null;
@ -312,7 +315,8 @@ public class BoardActivity extends XWActivity
if ( CHAT_REQUEST == requestCode ) {
String msg = data.getStringExtra( "chat" );
if ( null != msg && msg.length() > 0 ) {
m_jniThread.handle( JNICmd.CMD_SENDCHAT, msg );
m_pendingChats.add( msg );
trySendChats();
}
}
}
@ -1130,6 +1134,8 @@ public class BoardActivity extends XWActivity
if ( 0 != flags ) {
DBUtils.setMsgFlags( m_path, GameSummary.MSG_FLAGS_NONE );
}
trySendChats();
}
} // loadGame
@ -1313,4 +1319,14 @@ public class BoardActivity extends XWActivity
}
}
private void trySendChats()
{
if ( null != m_jniThread ) {
Iterator<String> iter = m_pendingChats.iterator();
while ( iter.hasNext() ) {
m_jniThread.handle( JNICmd.CMD_SENDCHAT, iter.next() );
}
}
}
} // class BoardActivity