erase the static bitmap so we don't show the previous board prior to

drawing the new one.
This commit is contained in:
Andy2 2011-07-20 18:48:50 -07:00
parent de16ee93d7
commit 9bf22c12f4

View file

@ -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 );