check that default dict exists and if it doesn't use same as if hadn't

been specified.  Catches case where dict is downloaded, made new-game
default, and then deleted.
This commit is contained in:
Andy2 2010-10-26 18:20:49 -07:00
parent 26210e1cf2
commit 1ceea2cde2
2 changed files with 17 additions and 1 deletions

View file

@ -243,6 +243,22 @@ public class GameUtils {
return al.toArray( new String[al.size()] );
}
public static boolean dictExists( Context context, String name )
{
boolean exists = dictIsBuiltin( context, name );
if ( !exists ) {
name = addDictExtn( name );
try {
FileInputStream fis = context.openFileInput( name );
fis.close();
exists = true;
} catch ( java.io.FileNotFoundException fnf ) {
} catch ( java.io.IOException ioe ) {
}
}
return exists;
}
public static boolean dictIsBuiltin( Context context, String name )
{
boolean builtin = false;

View file

@ -206,7 +206,7 @@ public class CommonPrefs {
public static String getDefaultDict( Context context )
{
String value = getString( context, R.string.key_default_dict );
if ( value.equals("") ) {
if ( value.equals("") || !GameUtils.dictExists( context, value ) ) {
value = GameUtils.dictList( context )[0];
}
return value;