Compare commits

...

1 Commits

Author SHA1 Message Date
Dennis Guse 979178a6f1 Bugfix: crash when exporting zero tracks.
Fixes #2285
2026-02-21 14:40:17 +01:00
@@ -167,8 +167,11 @@ public class ExportActivity extends AbstractActivity {
new Thread(() -> { new Thread(() -> {
directoryFiles = ExportUtils.getAllFiles(ExportActivity.this, documentFile.getUri()); directoryFiles = ExportUtils.getAllFiles(ExportActivity.this, documentFile.getUri());
runOnUiThread(() -> { runOnUiThread(() -> {
createExportTasks(allInOneFile); if (createExportTasks(allInOneFile)) {
nextExport(null); nextExport(null);
} else {
onExportEnded();
}
}); });
}).start(); }).start();
} else { } else {
@@ -217,8 +220,12 @@ public class ExportActivity extends AbstractActivity {
exportTasks.clear(); exportTasks.clear();
} }
private void createExportTasks(boolean allInOneFile) { private boolean createExportTasks(boolean allInOneFile) {
List<Track> tracks = contentProviderUtils.getTracks(); List<Track> tracks = contentProviderUtils.getTracks();
if (tracks.isEmpty()) {
return false;
}
exportTasks = new ArrayList<>(); exportTasks = new ArrayList<>();
if (allInOneFile) { if (allInOneFile) {
String filename = "OpenTracks-Backup"; String filename = "OpenTracks-Backup";
@@ -227,6 +234,7 @@ public class ExportActivity extends AbstractActivity {
exportTasks.addAll(tracks.stream().map(it -> new ExportTask(null, trackFileFormat, List.of(it.id()))).toList()); exportTasks.addAll(tracks.stream().map(it -> new ExportTask(null, trackFileFormat, List.of(it.id()))).toList());
} }
trackExportTotalCount = exportTasks.size(); trackExportTotalCount = exportTasks.size();
return true;
} }
/** /**
@@ -391,7 +399,7 @@ public class ExportActivity extends AbstractActivity {
/** /**
* Try to resolve the conflict if user gave the info needed. * Try to resolve the conflict if user gave the info needed.
* Otherwise shows the buttons and views needed to gives the user the possibility of take a decision. * Otherwise, shows the buttons and views needed to gives the user the possibility of take a decision.
* *
* @return true if it could resolve the conflict or false otherwise. * @return true if it could resolve the conflict or false otherwise.
*/ */