From 9bf22c12f406b8f792f39c4cecf540b900e14cdc Mon Sep 17 00:00:00 2001 From: Andy2 Date: Wed, 20 Jul 2011 18:48:50 -0700 Subject: [PATCH] erase the static bitmap so we don't show the previous board prior to drawing the new one. --- .../org/eehouse/android/xw4/BoardView.java | 77 +++++++++---------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java index 33af00257..6db8e6156 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -129,46 +129,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler, public BoardView( Context context, AttributeSet attrs ) { super( context, attrs ); - init( context ); - } - public boolean onTouchEvent( MotionEvent event ) - { - int action = event.getAction(); - int xx = (int)event.getX() - m_left; - int yy = (int)event.getY() - m_top; - - switch ( action ) { - case MotionEvent.ACTION_DOWN: - m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_DOWN, xx, yy ); - break; - case MotionEvent.ACTION_MOVE: - m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_MOVE, xx, yy ); - break; - case MotionEvent.ACTION_UP: - m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_UP, xx, yy ); - break; - default: - Utils.logf( "unknown action: " + action ); - Utils.logf( event.toString() ); - } - - return true; // required to get subsequent events - } - - // This will be called from the UI thread - @Override - protected void onDraw( Canvas canvas ) - { - synchronized( this ) { - if ( layoutBoardOnce() ) { - canvas.drawBitmap( s_bitmap, m_left, m_top, m_drawPaint ); - } - } - } - - private void init( Context context ) - { m_context = context; final float scale = getResources().getDisplayMetrics().density; m_defaultFontHt = (int)(MIN_FONT_DIPS * scale + 0.5f); @@ -209,6 +170,41 @@ public class BoardView extends View implements DrawCtx, BoardHandler, m_viewHandler = new Handler(); } + public boolean onTouchEvent( MotionEvent event ) + { + int action = event.getAction(); + int xx = (int)event.getX() - m_left; + int yy = (int)event.getY() - m_top; + + switch ( action ) { + case MotionEvent.ACTION_DOWN: + m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_DOWN, xx, yy ); + break; + case MotionEvent.ACTION_MOVE: + m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_MOVE, xx, yy ); + break; + case MotionEvent.ACTION_UP: + m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_UP, xx, yy ); + break; + default: + Utils.logf( "unknown action: " + action ); + Utils.logf( event.toString() ); + } + + return true; // required to get subsequent events + } + + // This will be called from the UI thread + @Override + protected void onDraw( Canvas canvas ) + { + synchronized( this ) { + if ( layoutBoardOnce() ) { + canvas.drawBitmap( s_bitmap, m_left, m_top, m_drawPaint ); + } + } + } + private BoardDims figureBoardDims( int width, int height, CurGameInfo gi ) { @@ -285,6 +281,9 @@ public class BoardView extends View implements DrawCtx, BoardHandler, } m_canvas = new Canvas( s_bitmap ); + // Clear it + fillRect( new Rect( 0, 0, width, height ), WHITE ); + // need to synchronize?? m_jniThread.handle( JNIThread.JNICmd.CMD_LAYOUT, dims ); m_jniThread.handle( JNIThread.JNICmd.CMD_DRAW );