Skip to content

Commit

Permalink
Fix lost sorting mode for empty sub folders
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-kutz committed Dec 2, 2024
1 parent 69362f3 commit 86a9948
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class TrackFolderLoaderTask(

if (file.isDirectory()) {
val subfolder = TrackFolder(file, folder)
subfolder.dirItem = GpxDbHelper.getGpxDirItem(file)
launch {
log.info("Loading track subfolder = $subfolder")
scanFolder(subfolder, progress, trackItems)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.osmand.shared.gpx.data

import net.osmand.shared.gpx.GpxDirItem
import net.osmand.shared.gpx.GpxHelper
import net.osmand.shared.gpx.TrackItem
import net.osmand.shared.gpx.filters.TrackFolderAnalysis
Expand All @@ -17,6 +18,7 @@ class TrackFolder(dirFile: KFile, parentFolder: TrackFolder?) :
private var flattenedSubFolders: List<TrackFolder>? = null
private var folderAnalysis: TrackFolderAnalysis? = null
private var lastModified: Long = -1
var dirItem: GpxDirItem? = null

init {
this.dirFile = dirFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.osmand.plus.settings.enums.TracksSortMode;
import net.osmand.shared.gpx.GpxDataItem;
import net.osmand.shared.gpx.GpxDbHelper;
import net.osmand.shared.gpx.GpxDirItem;
import net.osmand.shared.gpx.SmartFolderHelper;
import net.osmand.shared.gpx.data.SmartFolder;
import net.osmand.shared.io.KFile;
Expand Down Expand Up @@ -72,15 +73,23 @@ private Set<String> collectStandardDirectoriesIds() {
Set<String> result = new HashSet<>();
// add root directory
result.add("");
// collect all subdirectories which contains at least one gpx track
// collect all directories registered in tracks DB
Set<String> absolutePaths = new HashSet<>();
for (GpxDirItem item : gpxDbHelper.getDirItems()) {
KFile file = item.getFile();
absolutePaths.add(file.absolutePath());
}
// collect all subdirectories which contain at least one gpx track
for (GpxDataItem item : gpxDbHelper.getItems()) {
KFile file = item.getFile();
KFile directory = file.getParentFile();
if (directory != null) {
String path = directory.absolutePath();
result.add(getFolderIdV2(path));
absolutePaths.add(directory.absolutePath());
}
}
for (String absolutePath : absolutePaths) {
result.add(getFolderIdV2(absolutePath));
}
return result;
}

Expand Down

0 comments on commit 86a9948

Please sign in to comment.