Fix null pointer exception

This commit is contained in:
Victor Shcherb 2012-08-04 13:47:26 +03:00
parent 18754b6b13
commit 4342c4d138
2 changed files with 13 additions and 2 deletions

View file

@ -147,7 +147,17 @@ public class GPXUtilities {
}
public boolean isEmpty() {
return tracks.isEmpty() && points.isEmpty() && routes.isEmpty();
for (Track t : tracks) {
if (t.segments != null) {
for (TrkSegment s : t.segments) {
boolean tracksEmpty = s.points.isEmpty();
if (!tracksEmpty) {
return false;
}
}
}
}
return points.isEmpty() && routes.isEmpty();
}

View file

@ -138,7 +138,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
for (final String f : data.keySet()) {
File fout = new File(dir, f + ".gpx"); //$NON-NLS-1$
if (!data.get(f).isEmpty()) {
String fileName = f + "_" + new SimpleDateFormat("HH-mm_EEE").format(new Date(data.get(f).findPointToShow().time)); //$NON-NLS-1$
WptPt pt = data.get(f).findPointToShow();
String fileName = f + "_" + new SimpleDateFormat("HH-mm_EEE").format(new Date(pt.time)); //$NON-NLS-1$
fout = new File(dir, fileName + ".gpx"); //$NON-NLS-1$
int ind = 1;
while (fout.exists()) {