mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-11 16:42:41 +01:00
DroidFish: Avoid crash if "Scid on the go" misbehaves.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user