mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-11-23 11:31:33 +01:00
Handle pasting of multiple PGN games into DroidFish
This commit is contained in:
parent
26d03e7d91
commit
6531917212
|
@ -2287,7 +2287,22 @@ public class DroidFish extends Activity
|
|||
for (int i = 0; i < clip.getItemCount(); i++)
|
||||
fenPgn.append(clip.getItemAt(i).coerceToText(getApplicationContext()));
|
||||
try {
|
||||
ctrl.setFENOrPGN(fenPgn.toString());
|
||||
String fenPgnData = fenPgn.toString();
|
||||
Pair<GameInfoResult,ArrayList<GameInfo>> gi = PGNFile.getGameInfo(fenPgnData, 2);
|
||||
if (gi.first == GameInfoResult.OK && gi.second.size() > 1) {
|
||||
String sep = File.separator;
|
||||
String fn = Environment.getExternalStorageDirectory() + sep +
|
||||
pgnDir + sep + ".sharedfile.pgn";
|
||||
try (FileOutputStream writer = new FileOutputStream(fn)) {
|
||||
writer.write(fenPgnData.getBytes());
|
||||
writer.close();
|
||||
loadPGNFromFile(fn);
|
||||
} catch (IOException ex) {
|
||||
ctrl.setFENOrPGN(fenPgnData);
|
||||
}
|
||||
} else {
|
||||
ctrl.setFENOrPGN(fenPgnData);
|
||||
}
|
||||
setBoardFlip(true);
|
||||
} catch (ChessParseError e) {
|
||||
DroidFishApp.toast(getParseErrString(e), Toast.LENGTH_SHORT);
|
||||
|
|
Loading…
Reference in New Issue
Block a user