mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
Move jni calls for Game menu items into jni thread
This commit is contained in:
parent
b3cf0b41e1
commit
f7907c866d
2 changed files with 38 additions and 12 deletions
|
@ -162,6 +162,11 @@ public class BoardActivity extends Activity implements XW_UtilCtxt, Runnable {
|
|||
case JNIThread.DRAW:
|
||||
m_view.invalidate();
|
||||
break;
|
||||
case JNIThread.DIALOG:
|
||||
m_dlgBytes = (String)msg.obj;
|
||||
m_dlgTitle = msg.arg1;
|
||||
showDialog( DLG_OKONLY );
|
||||
break;
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
@ -242,22 +247,16 @@ public class BoardActivity extends Activity implements XW_UtilCtxt, Runnable {
|
|||
break;
|
||||
|
||||
case R.id.board_menu_game_counts:
|
||||
handled = true;
|
||||
m_dlgBytes = XwJNI.server_formatDictCounts( m_jniGamePtr, 3 );
|
||||
m_dlgTitle = R.string.counts_values_title;
|
||||
showDialog( DLG_OKONLY );
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_COUNTS_VALUES,
|
||||
R.string.counts_values_title );
|
||||
break;
|
||||
case R.id.board_menu_game_left:
|
||||
handled = true;
|
||||
m_dlgBytes = XwJNI.board_formatRemainingTiles( m_jniGamePtr );
|
||||
m_dlgTitle = R.string.tiles_left_title;
|
||||
showDialog( DLG_OKONLY );
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_REMAINING,
|
||||
R.string.tiles_left_title );
|
||||
break;
|
||||
case R.id.board_menu_game_history:
|
||||
boolean gameOver = XwJNI.server_getGameIsOver( m_jniGamePtr );
|
||||
m_dlgBytes = XwJNI.model_writeGameHistory( m_jniGamePtr, gameOver );
|
||||
m_dlgTitle = R.string.history_title;
|
||||
showDialog( DLG_OKONLY );
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_HISTORY,
|
||||
R.string.history_title );
|
||||
break;
|
||||
|
||||
case R.id.board_menu_game_info:
|
||||
|
|
|
@ -29,10 +29,14 @@ public class JNIThread extends Thread {
|
|||
CMD_HINT,
|
||||
CMD_NEXT_HINT,
|
||||
CMD_VALUES,
|
||||
CMD_COUNTS_VALUES,
|
||||
CMD_REMAINING,
|
||||
CMD_HISTORY,
|
||||
};
|
||||
|
||||
public static final int RUNNING = 1;
|
||||
public static final int DRAW = 2;
|
||||
public static final int DIALOG = 3;
|
||||
|
||||
private boolean m_stopped = false;
|
||||
private int m_jniGamePtr;
|
||||
|
@ -83,6 +87,11 @@ public class JNIThread extends Thread {
|
|||
return draw;
|
||||
}
|
||||
|
||||
private void sendForDialog( int titleArg, String text )
|
||||
{
|
||||
Message.obtain( m_handler, DIALOG, titleArg, 0, text ).sendToTarget();
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
boolean[] barr = new boolean[1]; // scratch boolean
|
||||
|
@ -161,6 +170,24 @@ public class JNIThread extends Thread {
|
|||
draw = XwJNI.board_toggle_showValues( m_jniGamePtr );
|
||||
break;
|
||||
|
||||
case CMD_COUNTS_VALUES:
|
||||
sendForDialog( ((Integer)args[0]).intValue(),
|
||||
XwJNI.server_formatDictCounts( m_jniGamePtr, 3 )
|
||||
);
|
||||
break;
|
||||
case CMD_REMAINING:
|
||||
sendForDialog( ((Integer)args[0]).intValue(),
|
||||
XwJNI.board_formatRemainingTiles( m_jniGamePtr )
|
||||
);
|
||||
break;
|
||||
case CMD_HISTORY:
|
||||
boolean gameOver = XwJNI.server_getGameIsOver( m_jniGamePtr );
|
||||
sendForDialog( ((Integer)args[0]).intValue(),
|
||||
XwJNI.model_writeGameHistory( m_jniGamePtr,
|
||||
gameOver )
|
||||
);
|
||||
break;
|
||||
|
||||
case CMD_TIMER_FIRED:
|
||||
draw = XwJNI.timerFired( m_jniGamePtr,
|
||||
((Integer)args[0]).intValue(),
|
||||
|
|
Loading…
Add table
Reference in a new issue