mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-13 17:32:40 +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() {
|
private final void selectScidFile() {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setComponent(new ComponentName("org.scid.android",
|
intent.setComponent(new ComponentName("org.scid.android",
|
||||||
"org.scid.android.SelectFileActivity"));
|
"org.scid.android.SelectFileActivity"));
|
||||||
intent.setAction(".si4");
|
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;
|
final static int FT_NONE = 0;
|
||||||
@@ -3140,12 +3152,4 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
currNode = node;
|
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() {
|
private Cursor getListCursor() {
|
||||||
String scidFileName = fileName.substring(0, fileName.indexOf("."));
|
String scidFileName = fileName.substring(0, fileName.indexOf("."));
|
||||||
String[] proj = new String[]{"_id", "summary"};
|
String[] proj = new String[]{"_id", "summary"};
|
||||||
Cursor cursor = managedQuery(Uri.parse("content://org.scid.database.scidprovider/games"),
|
try {
|
||||||
proj, scidFileName, null, null);
|
Cursor cursor = managedQuery(Uri.parse("content://org.scid.database.scidprovider/games"),
|
||||||
idIdx = cursor.getColumnIndex("_id");
|
proj, scidFileName, null, null);
|
||||||
summaryIdx = cursor.getColumnIndex("summary");
|
idIdx = cursor.getColumnIndex("_id");
|
||||||
return cursor;
|
summaryIdx = cursor.getColumnIndex("summary");
|
||||||
|
return cursor;
|
||||||
|
} catch (Throwable t) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Cursor getOneGameCursor(int gameId) {
|
private Cursor getOneGameCursor(int gameId) {
|
||||||
String scidFileName = fileName.substring(0, fileName.indexOf("."));
|
String scidFileName = fileName.substring(0, fileName.indexOf("."));
|
||||||
String[] proj = new String[]{"pgn"};
|
String[] proj = new String[]{"pgn"};
|
||||||
String uri = String.format("content://org.scid.database.scidprovider/games/%d", gameId);
|
try {
|
||||||
Cursor cursor = managedQuery(Uri.parse(uri),
|
String uri = String.format("content://org.scid.database.scidprovider/games/%d", gameId);
|
||||||
proj, scidFileName, null, null);
|
Cursor cursor = managedQuery(Uri.parse(uri),
|
||||||
return cursor;
|
proj, scidFileName, null, null);
|
||||||
|
return cursor;
|
||||||
|
} catch (Throwable t) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addGameInfo(Cursor cursor) {
|
private void addGameInfo(Cursor cursor) {
|
||||||
|
|||||||
Reference in New Issue
Block a user