mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
save into DB rather than drop chat messages received in background.
Still need to add UI to let user know a new message is there.
This commit is contained in:
parent
a954977e56
commit
0c9b053844
2 changed files with 38 additions and 1 deletions
|
@ -129,6 +129,13 @@ public class GameUtils {
|
|||
|
||||
public static void loadMakeGame( Context context, int gamePtr,
|
||||
CurGameInfo gi, String path )
|
||||
{
|
||||
loadMakeGame( context, gamePtr, gi, null, path );
|
||||
}
|
||||
|
||||
public static void loadMakeGame( Context context, int gamePtr,
|
||||
CurGameInfo gi, UtilCtxt util,
|
||||
String path )
|
||||
{
|
||||
byte[] stream = savedGame( context, path );
|
||||
XwJNI.gi_from_stream( gi, stream );
|
||||
|
@ -137,6 +144,7 @@ public class GameUtils {
|
|||
boolean madeGame = XwJNI.game_makeFromStream( gamePtr, stream,
|
||||
JNIUtilsImpl.get(), gi,
|
||||
dictBytes, gi.dictName,
|
||||
util,
|
||||
CommonPrefs.get(context));
|
||||
if ( !madeGame ) {
|
||||
XwJNI.game_makeNewGame( gamePtr, gi, JNIUtilsImpl.get(),
|
||||
|
@ -361,6 +369,21 @@ public class GameUtils {
|
|||
activity.finish();
|
||||
}
|
||||
|
||||
private static class FeedUtilsImpl extends UtilCtxtImpl {
|
||||
private Context m_context;
|
||||
private String m_path;
|
||||
|
||||
public FeedUtilsImpl( Context context, String path )
|
||||
{
|
||||
m_context = context;
|
||||
m_path = path;
|
||||
}
|
||||
public void showChat( String msg )
|
||||
{
|
||||
DBUtils.appendChatHistory( m_context, m_path, msg, false );
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean feedMessages( Context context, String relayID,
|
||||
byte[][] msgs )
|
||||
{
|
||||
|
@ -369,7 +392,9 @@ public class GameUtils {
|
|||
if ( null != path ) {
|
||||
int gamePtr = XwJNI.initJNI();
|
||||
CurGameInfo gi = new CurGameInfo( context );
|
||||
loadMakeGame( context, gamePtr, gi, path );
|
||||
loadMakeGame( context, gamePtr, gi,
|
||||
new FeedUtilsImpl(context, path),
|
||||
path );
|
||||
|
||||
for ( byte[] msg : msgs ) {
|
||||
draw = XwJNI.game_receiveMessage( gamePtr, msg ) || draw;
|
||||
|
|
|
@ -93,6 +93,18 @@ public class XwJNI {
|
|||
(TransportProcs)null );
|
||||
}
|
||||
|
||||
public static boolean game_makeFromStream( int gamePtr,
|
||||
byte[] stream,
|
||||
JNIUtils jniu,
|
||||
CurGameInfo gi,
|
||||
byte[] dict, String dictName,
|
||||
UtilCtxt util,
|
||||
CommonPrefs cp ) {
|
||||
return game_makeFromStream( gamePtr, stream, gi, dict, dictName,
|
||||
util, jniu, (DrawCtx)null, cp,
|
||||
(TransportProcs)null );
|
||||
}
|
||||
|
||||
public static native boolean game_receiveMessage( int gamePtr,
|
||||
byte[] stream );
|
||||
public static native void game_summarize( int gamePtr, GameSummary summary );
|
||||
|
|
Loading…
Reference in a new issue