mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-27 07:58:49 +01:00
erase the static bitmap so we don't show the previous board prior to
drawing the new one.
This commit is contained in:
parent
de16ee93d7
commit
9bf22c12f4
1 changed files with 38 additions and 39 deletions
|
@ -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 );
|
||||
|
|
Loading…
Add table
Reference in a new issue