mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
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:
parent
26210e1cf2
commit
1ceea2cde2
2 changed files with 17 additions and 1 deletions
|
@ -243,6 +243,22 @@ public class GameUtils {
|
||||||
return al.toArray( new String[al.size()] );
|
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 )
|
public static boolean dictIsBuiltin( Context context, String name )
|
||||||
{
|
{
|
||||||
boolean builtin = false;
|
boolean builtin = false;
|
||||||
|
|
|
@ -206,7 +206,7 @@ public class CommonPrefs {
|
||||||
public static String getDefaultDict( Context context )
|
public static String getDefaultDict( Context context )
|
||||||
{
|
{
|
||||||
String value = getString( context, R.string.key_default_dict );
|
String value = getString( context, R.string.key_default_dict );
|
||||||
if ( value.equals("") ) {
|
if ( value.equals("") || !GameUtils.dictExists( context, value ) ) {
|
||||||
value = GameUtils.dictList( context )[0];
|
value = GameUtils.dictList( context )[0];
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
|
Loading…
Reference in a new issue