mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-14 01:42:40 +01:00
DroidFish: Fixed warnings found by FindBugs.
This commit is contained in:
@@ -227,15 +227,15 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
if ((intent.getData() != null) && intent.getScheme().equals("content")) {
|
if ((intent.getData() != null) && intent.getScheme().equals("content")) {
|
||||||
ContentResolver resolver = getContentResolver();
|
ContentResolver resolver = getContentResolver();
|
||||||
InputStream in = resolver.openInputStream(intent.getData());
|
InputStream in = resolver.openInputStream(intent.getData());
|
||||||
String tmp = "";
|
StringBuilder sb = new StringBuilder();
|
||||||
while (true) {
|
while (true) {
|
||||||
byte[] buffer = new byte[16384];
|
byte[] buffer = new byte[16384];
|
||||||
int len = in.read(buffer);
|
int len = in.read(buffer);
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
break;
|
break;
|
||||||
tmp += new String(buffer, 0, len);
|
sb.append(new String(buffer, 0, len));
|
||||||
}
|
}
|
||||||
pgn = tmp;
|
pgn = sb.toString();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Toast.makeText(getApplicationContext(), "Failed to read pgn data", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), "Failed to read pgn data", Toast.LENGTH_SHORT).show();
|
||||||
|
|||||||
@@ -325,7 +325,8 @@ public class PGNFile {
|
|||||||
copyData(fileReader, fileWriter, fileReader.length() - gi.endPos);
|
copyData(fileReader, fileWriter, fileReader.length() - gi.endPos);
|
||||||
fileReader.close();
|
fileReader.close();
|
||||||
fileWriter.close();
|
fileWriter.close();
|
||||||
tmpFile.renameTo(fileName);
|
if (!tmpFile.renameTo(fileName))
|
||||||
|
throw new IOException();
|
||||||
|
|
||||||
// Update gamesInFile
|
// Update gamesInFile
|
||||||
if (gamesInFile != null) {
|
if (gamesInFile != null) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import java.util.Collections;
|
|||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.petero.droidfish.PGNOptions;
|
import org.petero.droidfish.PGNOptions;
|
||||||
import org.petero.droidfish.gamelogic.Game.GameState;
|
import org.petero.droidfish.gamelogic.Game.GameState;
|
||||||
@@ -1364,8 +1365,9 @@ public class GameTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setHeaders(Map<String,String> headers) {
|
void setHeaders(Map<String,String> headers) {
|
||||||
for (String tag : headers.keySet()) {
|
for (Entry<String, String> entry : headers.entrySet()) {
|
||||||
String val = headers.get(tag);
|
String tag = entry.getKey();
|
||||||
|
String val = entry.getValue();
|
||||||
if (tag.equals("Event")) event = val;
|
if (tag.equals("Event")) event = val;
|
||||||
else if (tag.equals("Site")) site = val;
|
else if (tag.equals("Site")) site = val;
|
||||||
else if (tag.equals("Date")) date = val;
|
else if (tag.equals("Date")) date = val;
|
||||||
|
|||||||
Reference in New Issue
Block a user