mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-07 20:46:17 +01:00
fix so board still works after reloading, e.g. after turning screen
off and back on.
This commit is contained in:
parent
da3215c116
commit
7cf297ad0e
3 changed files with 33 additions and 5 deletions
|
@ -163,6 +163,14 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
||||||
fillRect( m_boundsScratch, WHITE );
|
fillRect( m_boundsScratch, WHITE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setJNIThread( JNIThread jniThread )
|
||||||
|
{
|
||||||
|
if ( ! jniThread.equals( m_jniThread ) ) {
|
||||||
|
DbgUtils.logf( "BoardCanvas changing threads" );
|
||||||
|
m_jniThread = jniThread;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getCurPlayer()
|
public int getCurPlayer()
|
||||||
{
|
{
|
||||||
return m_trayOwner;
|
return m_trayOwner;
|
||||||
|
@ -528,7 +536,8 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
||||||
m_dictChars = XwJNI.dict_getChars( dictPtr );
|
m_dictChars = XwJNI.dict_getChars( dictPtr );
|
||||||
// draw again
|
// draw again
|
||||||
if ( null != m_jniThread ) {
|
if ( null != m_jniThread ) {
|
||||||
m_jniThread.handle( JNIThread.JNICmd.CMD_DRAW );
|
m_jniThread.handle( JNIThread.JNICmd
|
||||||
|
.CMD_INVALALL );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -251,7 +251,10 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
|
||||||
if ( null == m_canvas ) {
|
if ( null == m_canvas ) {
|
||||||
DbgUtils.logf( "layoutBoardOnce: allocating canvas for %d, %d",
|
DbgUtils.logf( "layoutBoardOnce: allocating canvas for %d, %d",
|
||||||
bmWidth, bmHeight );
|
bmWidth, bmHeight );
|
||||||
m_canvas = new BoardCanvas( m_parent, s_bitmap, m_jniThread, m_dims );
|
m_canvas = new BoardCanvas( m_parent, s_bitmap, m_jniThread,
|
||||||
|
m_dims );
|
||||||
|
} else {
|
||||||
|
m_canvas.setJNIThread( m_jniThread );
|
||||||
}
|
}
|
||||||
m_jniThread.handle( JNIThread.JNICmd.CMD_SETDRAW, m_canvas );
|
m_jniThread.handle( JNIThread.JNICmd.CMD_SETDRAW, m_canvas );
|
||||||
m_jniThread.handle( JNIThread.JNICmd.CMD_DRAW );
|
m_jniThread.handle( JNIThread.JNICmd.CMD_DRAW );
|
||||||
|
@ -270,7 +273,6 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
|
||||||
int gamePtr, CurGameInfo gi,
|
int gamePtr, CurGameInfo gi,
|
||||||
CommsAddrRec.CommsConnType connType )
|
CommsAddrRec.CommsConnType connType )
|
||||||
{
|
{
|
||||||
DbgUtils.logf( "startHandling()" );
|
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
m_jniThread = thread;
|
m_jniThread = thread;
|
||||||
m_jniGamePtr = gamePtr;
|
m_jniGamePtr = gamePtr;
|
||||||
|
@ -279,6 +281,11 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
|
||||||
m_layoutWidth = 0;
|
m_layoutWidth = 0;
|
||||||
m_layoutHeight = 0;
|
m_layoutHeight = 0;
|
||||||
|
|
||||||
|
// Set the jni layout if we already have one
|
||||||
|
if ( null != m_dims ) {
|
||||||
|
m_jniThread.handle( JNIThread.JNICmd.CMD_LAYOUT, m_dims );
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure we draw. Sometimes when we're reloading after
|
// Make sure we draw. Sometimes when we're reloading after
|
||||||
// an obsuring Activity goes away we otherwise won't.
|
// an obsuring Activity goes away we otherwise won't.
|
||||||
invalidate();
|
invalidate();
|
||||||
|
|
|
@ -361,8 +361,15 @@ public class JNIThread extends Thread {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_LAYOUT:
|
case CMD_LAYOUT:
|
||||||
doLayout( (Integer)args[0], (Integer)args[1], (Integer)args[2],
|
Object args0 = args[0];
|
||||||
(Integer)args[3] );
|
BoardDims dims = null;
|
||||||
|
if ( args0 instanceof BoardDims ) {
|
||||||
|
dims = (BoardDims)args0;
|
||||||
|
XwJNI.board_applyLayout( m_jniGamePtr, dims );
|
||||||
|
} else {
|
||||||
|
doLayout( (Integer)args0, (Integer)args[1],
|
||||||
|
(Integer)args[2], (Integer)args[3] );
|
||||||
|
}
|
||||||
draw = true;
|
draw = true;
|
||||||
// check and disable zoom button at limit
|
// check and disable zoom button at limit
|
||||||
handle( JNICmd.CMD_ZOOM, 0 );
|
handle( JNICmd.CMD_ZOOM, 0 );
|
||||||
|
@ -644,6 +651,11 @@ public class JNIThread extends Thread {
|
||||||
{
|
{
|
||||||
QueueElem elem = new QueueElem( cmd, true, args );
|
QueueElem elem = new QueueElem( cmd, true, args );
|
||||||
m_queue.add( elem );
|
m_queue.add( elem );
|
||||||
|
if ( m_stopped ) {
|
||||||
|
DbgUtils.logf( "WARNING: adding %s to stopped thread!!!",
|
||||||
|
cmd.toString() );
|
||||||
|
DbgUtils.printStack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void run( boolean isUI, Runnable runnable )
|
// public void run( boolean isUI, Runnable runnable )
|
||||||
|
|
Loading…
Add table
Reference in a new issue