check if dict missing and warn rather than do anything that will crash

if it's not there.  Ideally I could open the config dialog so user
could change the dict but that isn't working.  Maybe just offer to
open it after swapping in the default dict?
This commit is contained in:
Andy2 2010-11-18 19:00:49 -08:00
parent 7921ddca10
commit 198534dce3

View file

@ -279,11 +279,13 @@ public class GamesList extends XWListActivity
} }
GameUtils.doConfig( this, path, clazz ); GameUtils.doConfig( this, path, clazz );
} else { } else {
File file = new File( path ); if ( checkWarnNoDict( path ) ) {
Uri uri = Uri.fromFile( file ); File file = new File( path );
Intent intent = new Intent( Intent.ACTION_EDIT, uri, Uri uri = Uri.fromFile( file );
this, BoardActivity.class ); Intent intent = new Intent( Intent.ACTION_EDIT, uri,
startActivity( intent ); this, BoardActivity.class );
startActivity( intent );
}
} }
m_invalPath = path; m_invalPath = path;
} }
@ -306,13 +308,7 @@ public class GamesList extends XWListActivity
showConfirmThen( R.string.confirm_delete, lstnr ); showConfirmThen( R.string.confirm_delete, lstnr );
} else { } else {
String invalPath = null; String invalPath = null;
String[] missingName = new String[1]; if ( checkWarnNoDict( path ) ) {
int[] missingLang = new int[1];
boolean hasDict = GameUtils.gameDictHere( this, path,
missingName, missingLang );
if ( !hasDict ) {
showNoDict( missingName[0], missingLang[0] );
} else {
switch ( menuID ) { switch ( menuID ) {
case R.id.list_item_reset: case R.id.list_item_reset:
lstnr = new DialogInterface.OnClickListener() { lstnr = new DialogInterface.OnClickListener() {
@ -371,6 +367,18 @@ public class GamesList extends XWListActivity
return handled; return handled;
} // handleMenuItem } // handleMenuItem
private boolean checkWarnNoDict( String path )
{
String[] missingName = new String[1];
int[] missingLang = new int[1];
boolean hasDict = GameUtils.gameDictHere( this, path,
missingName, missingLang );
if ( !hasDict ) {
showNoDict( missingName[0], missingLang[0] );
}
return hasDict;
}
private String saveNew( CurGameInfo gi ) private String saveNew( CurGameInfo gi )
{ {
String path = null; String path = null;
@ -388,5 +396,4 @@ public class GamesList extends XWListActivity
onContentChanged(); onContentChanged();
return path; return path;
} }
} }