mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
fix NPE by refusing to calc font info when don't have char set, and by
resusing to draw when don't have font info. Until other bugs got fixed this must meant lots of all-white boards, and it's not strictly necessary, but is an improvement.
This commit is contained in:
parent
09100dcb2c
commit
2572af039d
1 changed files with 81 additions and 75 deletions
|
@ -463,12 +463,13 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
public boolean drawCell( final Rect rect, String text, int tile, int owner,
|
public boolean drawCell( final Rect rect, String text, int tile, int owner,
|
||||||
int bonus, int hintAtts, final int flags )
|
int bonus, int hintAtts, final int flags )
|
||||||
{
|
{
|
||||||
|
boolean canDraw = figureFontDims();
|
||||||
|
if ( canDraw ) {
|
||||||
int backColor;
|
int backColor;
|
||||||
boolean empty = 0 != (flags & (CELL_DRAGSRC|CELL_ISEMPTY));
|
boolean empty = 0 != (flags & (CELL_DRAGSRC|CELL_ISEMPTY));
|
||||||
boolean pending = 0 != (flags & CELL_HIGHLIGHT);
|
boolean pending = 0 != (flags & CELL_HIGHLIGHT);
|
||||||
String bonusStr = null;
|
String bonusStr = null;
|
||||||
|
|
||||||
figureFontDims();
|
|
||||||
|
|
||||||
if ( owner < 0 ) {
|
if ( owner < 0 ) {
|
||||||
owner = 0;
|
owner = 0;
|
||||||
|
@ -522,8 +523,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
m_canvas.drawRect( rect, m_strokePaint );
|
m_canvas.drawRect( rect, m_strokePaint );
|
||||||
|
|
||||||
drawCrosshairs( rect, flags );
|
drawCrosshairs( rect, flags );
|
||||||
|
}
|
||||||
return true;
|
return canDraw;
|
||||||
} // drawCell
|
} // drawCell
|
||||||
|
|
||||||
private boolean m_arrowHintShown = false;
|
private boolean m_arrowHintShown = false;
|
||||||
|
@ -710,7 +711,10 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
public void dictChanged( int playerNum, int dictPtr )
|
public void dictChanged( int playerNum, int dictPtr )
|
||||||
{
|
{
|
||||||
if ( m_dictPtr != dictPtr ) {
|
if ( m_dictPtr != dictPtr ) {
|
||||||
if ( m_dictPtr == 0 ||
|
if ( 0 == dictPtr ) {
|
||||||
|
m_fontDims = null;
|
||||||
|
m_dictChars = null;
|
||||||
|
} else if ( m_dictPtr == 0 ||
|
||||||
!XwJNI.dict_tilesAreSame( m_dictPtr, dictPtr ) ) {
|
!XwJNI.dict_tilesAreSame( m_dictPtr, dictPtr ) ) {
|
||||||
m_fontDims = null;
|
m_fontDims = null;
|
||||||
m_dictChars = XwJNI.dict_getChars( dictPtr );
|
m_dictChars = XwJNI.dict_getChars( dictPtr );
|
||||||
|
@ -807,8 +811,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
|
|
||||||
private void positionDrawTile( final Rect rect, String text, int val )
|
private void positionDrawTile( final Rect rect, String text, int val )
|
||||||
{
|
{
|
||||||
figureFontDims();
|
if ( figureFontDims() ) {
|
||||||
|
|
||||||
if ( null != text ) {
|
if ( null != text ) {
|
||||||
if ( null == m_letterRect ) {
|
if ( null == m_letterRect ) {
|
||||||
m_letterRect = new Rect( 0, 0, rect.width() * 3 / 4,
|
m_letterRect = new Rect( 0, 0, rect.width() * 3 / 4,
|
||||||
|
@ -832,6 +835,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
m_fillPaint );
|
m_fillPaint );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void drawCrosshairs( final Rect rect, final int flags )
|
private void drawCrosshairs( final Rect rect, final int flags )
|
||||||
{
|
{
|
||||||
|
@ -859,9 +863,10 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
m_canvas.drawRect( rect, m_fillPaint );
|
m_canvas.drawRect( rect, m_fillPaint );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void figureFontDims()
|
private boolean figureFontDims()
|
||||||
{
|
{
|
||||||
if ( null == m_fontDims ) {
|
if ( null == m_fontDims && null != m_dictChars ) {
|
||||||
|
|
||||||
final int ht = 24;
|
final int ht = 24;
|
||||||
final int width = 20;
|
final int width = 20;
|
||||||
|
|
||||||
|
@ -928,6 +933,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
|
|
||||||
m_fontDims = new FontDims( ht, topRow, bottomRow, maxWidth );
|
m_fontDims = new FontDims( ht, topRow, bottomRow, maxWidth );
|
||||||
}
|
}
|
||||||
|
return null != m_fontDims;
|
||||||
} // figureFontDims
|
} // figureFontDims
|
||||||
|
|
||||||
private void markBlank( final Rect rect, boolean whiteOnBlack )
|
private void markBlank( final Rect rect, boolean whiteOnBlack )
|
||||||
|
|
Loading…
Reference in a new issue