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 =
|
||||
cursor.getString( cursor.getColumnIndex(DBHelper.SCORES));
|
||||
StringTokenizer st = new StringTokenizer( scoresStr );
|
||||
int[] scores = new int[st.countTokens()];
|
||||
for ( int ii = 0; ii < scores.length; ++ii ) {
|
||||
Assert.assertTrue( st.hasMoreTokens() );
|
||||
String token = st.nextToken();
|
||||
scores[ii] = Integer.parseInt( token );
|
||||
if ( null != scoresStr ) {
|
||||
StringTokenizer st = new StringTokenizer( scoresStr );
|
||||
int[] scores = new int[st.countTokens()];
|
||||
for ( int ii = 0; ii < scores.length; ++ii ) {
|
||||
Assert.assertTrue( st.hasMoreTokens() );
|
||||
String token = st.nextToken();
|
||||
scores[ii] = Integer.parseInt( token );
|
||||
}
|
||||
summary.scores = scores;
|
||||
}
|
||||
summary.scores = scores;
|
||||
|
||||
int col = cursor.getColumnIndex( DBHelper.CONTYPE );
|
||||
if ( col >= 0 ) {
|
||||
|
@ -103,11 +105,13 @@ public class DBUtils {
|
|||
values.put( DBHelper.NUM_MOVES, summary.nMoves );
|
||||
values.put( DBHelper.GAME_OVER, summary.gameOver );
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for ( int score : summary.scores ) {
|
||||
sb.append( String.format( "%d ", score ) );
|
||||
if ( null != summary.scores ) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
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 ) {
|
||||
values.put( DBHelper.CONTYPE, summary.conType.ordinal() );
|
||||
|
|
Loading…
Reference in a new issue