mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
fix crash when copying a new game by testing for null scores array
This commit is contained in:
parent
5b336146c8
commit
ce2182e214
1 changed files with 15 additions and 11 deletions
|
@ -60,14 +60,16 @@ public class DBUtils {
|
||||||
|
|
||||||
String scoresStr =
|
String scoresStr =
|
||||||
cursor.getString( cursor.getColumnIndex(DBHelper.SCORES));
|
cursor.getString( cursor.getColumnIndex(DBHelper.SCORES));
|
||||||
StringTokenizer st = new StringTokenizer( scoresStr );
|
if ( null != scoresStr ) {
|
||||||
int[] scores = new int[st.countTokens()];
|
StringTokenizer st = new StringTokenizer( scoresStr );
|
||||||
for ( int ii = 0; ii < scores.length; ++ii ) {
|
int[] scores = new int[st.countTokens()];
|
||||||
Assert.assertTrue( st.hasMoreTokens() );
|
for ( int ii = 0; ii < scores.length; ++ii ) {
|
||||||
String token = st.nextToken();
|
Assert.assertTrue( st.hasMoreTokens() );
|
||||||
scores[ii] = Integer.parseInt( token );
|
String token = st.nextToken();
|
||||||
|
scores[ii] = Integer.parseInt( token );
|
||||||
|
}
|
||||||
|
summary.scores = scores;
|
||||||
}
|
}
|
||||||
summary.scores = scores;
|
|
||||||
|
|
||||||
int col = cursor.getColumnIndex( DBHelper.CONTYPE );
|
int col = cursor.getColumnIndex( DBHelper.CONTYPE );
|
||||||
if ( col >= 0 ) {
|
if ( col >= 0 ) {
|
||||||
|
@ -103,11 +105,13 @@ public class DBUtils {
|
||||||
values.put( DBHelper.NUM_MOVES, summary.nMoves );
|
values.put( DBHelper.NUM_MOVES, summary.nMoves );
|
||||||
values.put( DBHelper.GAME_OVER, summary.gameOver );
|
values.put( DBHelper.GAME_OVER, summary.gameOver );
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer();
|
if ( null != summary.scores ) {
|
||||||
for ( int score : summary.scores ) {
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append( String.format( "%d ", score ) );
|
for ( int score : summary.scores ) {
|
||||||
|
sb.append( String.format( "%d ", score ) );
|
||||||
|
}
|
||||||
|
values.put( DBHelper.SCORES, sb.toString() );
|
||||||
}
|
}
|
||||||
values.put( DBHelper.SCORES, sb.toString() );
|
|
||||||
|
|
||||||
if ( null != summary.conType ) {
|
if ( null != summary.conType ) {
|
||||||
values.put( DBHelper.CONTYPE, summary.conType.ordinal() );
|
values.put( DBHelper.CONTYPE, summary.conType.ordinal() );
|
||||||
|
|
Loading…
Reference in a new issue