DroidFish: Avoid crash if "Scid on the go" misbehaves.

This commit is contained in:
Peter Osterlund
2012-09-28 17:03:11 +00:00
parent 0fd90e2550
commit b88ca87867
2 changed files with 30 additions and 18 deletions

View File

@@ -2711,12 +2711,24 @@ public class DroidFish extends Activity implements GUIInterface {
}
}
private final boolean hasScidProvider() {
List<ProviderInfo> providers = getPackageManager().queryContentProviders(null, 0, 0);
for (ProviderInfo info : providers)
if (info.authority.equals("org.scid.database.scidprovider"))
return true;
return false;
}
private final void selectScidFile() {
Intent intent = new Intent();
intent.setComponent(new ComponentName("org.scid.android",
"org.scid.android.SelectFileActivity"));
intent.setAction(".si4");
startActivityForResult(intent, RESULT_SELECT_SCID);
try {
startActivityForResult(intent, RESULT_SELECT_SCID);
} catch (ActivityNotFoundException e) {
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
}
}
final static int FT_NONE = 0;
@@ -3140,12 +3152,4 @@ public class DroidFish extends Activity implements GUIInterface {
currNode = node;
}
}
private final boolean hasScidProvider() {
List<ProviderInfo> providers = getPackageManager().queryContentProviders(null, 0, 0);
for (ProviderInfo info : providers)
if (info.authority.equals("org.scid.database.scidprovider"))
return true;
return false;
}
}

View File

@@ -255,20 +255,28 @@ public class LoadScid extends ListActivity {
private Cursor getListCursor() {
String scidFileName = fileName.substring(0, fileName.indexOf("."));
String[] proj = new String[]{"_id", "summary"};
Cursor cursor = managedQuery(Uri.parse("content://org.scid.database.scidprovider/games"),
proj, scidFileName, null, null);
idIdx = cursor.getColumnIndex("_id");
summaryIdx = cursor.getColumnIndex("summary");
return cursor;
try {
Cursor cursor = managedQuery(Uri.parse("content://org.scid.database.scidprovider/games"),
proj, scidFileName, null, null);
idIdx = cursor.getColumnIndex("_id");
summaryIdx = cursor.getColumnIndex("summary");
return cursor;
} catch (Throwable t) {
return null;
}
}
private Cursor getOneGameCursor(int gameId) {
String scidFileName = fileName.substring(0, fileName.indexOf("."));
String[] proj = new String[]{"pgn"};
String uri = String.format("content://org.scid.database.scidprovider/games/%d", gameId);
Cursor cursor = managedQuery(Uri.parse(uri),
proj, scidFileName, null, null);
return cursor;
try {
String uri = String.format("content://org.scid.database.scidprovider/games/%d", gameId);
Cursor cursor = managedQuery(Uri.parse(uri),
proj, scidFileName, null, null);
return cursor;
} catch (Throwable t) {
return null;
}
}
private void addGameInfo(Cursor cursor) {