save phony "new game" even if names not set

This commit is contained in:
ehouse 2010-01-13 12:57:02 +00:00
parent cf60be5082
commit b2f0b91a23

View file

@ -1,3 +1,5 @@
/* -*- compile-command: "cd ../../../../../; ant reinstall"; -*- */
/* /*
* Copyright (C) 2007 The Android Open Source Project * Copyright (C) 2007 The Android Open Source Project
* *
@ -136,39 +138,36 @@ public class GameConfig extends Activity implements View.OnClickListener {
text = et.getText(); text = et.getText();
String name2 = text.toString(); String name2 = text.toString();
if ( name1.length() > 0 && name2.length() > 0 ) { Integer num = 0;
Integer num = 0; int ii;
int ii; String[] files = fileList();
String[] files = fileList(); String name = null;
String name = null;
while ( name == null ) { while ( name == null ) {
name = "game " + num.toString(); name = "game " + num.toString();
for ( ii = 0; ii < files.length; ++ii ) { for ( ii = 0; ii < files.length; ++ii ) {
Utils.logf( "comparing " + name + " with " + files[ii] ); Utils.logf( "comparing " + name + " with " + files[ii] );
if ( files[ii].equals(name) ) { if ( files[ii].equals(name) ) {
++num; ++num;
name = null; name = null;
}
} }
} }
Utils.logf( "using name " + name ); }
FileOutputStream out; FileOutputStream out;
try {
out = openFileOutput( name, MODE_PRIVATE );
PrintStream ps = new PrintStream( out );
ps.println( name1 );
ps.println( name2 );
ps.close();
try { try {
out = openFileOutput( name, MODE_PRIVATE ); out.close();
PrintStream ps = new PrintStream( out ); } catch ( java.io.IOException ex ) {
ps.println( name1 ); Utils.logf( "got IOException: " + ex.toString() );
ps.println( name2 );
ps.close();
try {
out.close();
} catch ( java.io.IOException ex ) {
Utils.logf( "got IOException: " + ex.toString() );
}
} catch ( java.io.FileNotFoundException ex ) {
Utils.logf( "got FileNotFoundException: " + ex.toString() );
} }
} catch ( java.io.FileNotFoundException ex ) {
Utils.logf( "got FileNotFoundException: " + ex.toString() );
} }
setResult( 1 ); setResult( 1 );