DroidFish: Fixed warnings found by FindBugs.

This commit is contained in:
Peter Osterlund
2011-12-04 11:35:36 +00:00
parent 68ecd0c854
commit ec8e082d5f
3 changed files with 9 additions and 6 deletions

View File

@@ -227,15 +227,15 @@ public class DroidFish extends Activity implements GUIInterface {
if ((intent.getData() != null) && intent.getScheme().equals("content")) {
ContentResolver resolver = getContentResolver();
InputStream in = resolver.openInputStream(intent.getData());
String tmp = "";
StringBuilder sb = new StringBuilder();
while (true) {
byte[] buffer = new byte[16384];
int len = in.read(buffer);
if (len <= 0)
break;
tmp += new String(buffer, 0, len);
sb.append(new String(buffer, 0, len));
}
pgn = tmp;
pgn = sb.toString();
}
} catch (IOException e) {
Toast.makeText(getApplicationContext(), "Failed to read pgn data", Toast.LENGTH_SHORT).show();

View File

@@ -325,7 +325,8 @@ public class PGNFile {
copyData(fileReader, fileWriter, fileReader.length() - gi.endPos);
fileReader.close();
fileWriter.close();
tmpFile.renameTo(fileName);
if (!tmpFile.renameTo(fileName))
throw new IOException();
// Update gamesInFile
if (gamesInFile != null) {

View File

@@ -29,6 +29,7 @@ import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.petero.droidfish.PGNOptions;
import org.petero.droidfish.gamelogic.Game.GameState;
@@ -1364,8 +1365,9 @@ public class GameTree {
}
void setHeaders(Map<String,String> headers) {
for (String tag : headers.keySet()) {
String val = headers.get(tag);
for (Entry<String, String> entry : headers.entrySet()) {
String tag = entry.getKey();
String val = entry.getValue();
if (tag.equals("Event")) event = val;
else if (tag.equals("Site")) site = val;
else if (tag.equals("Date")) date = val;