Skip to content

Commit

Permalink
Small bugfix for tabsSortModes cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sonora committed May 15, 2024
1 parent adffeaa commit a226f58
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;

import net.osmand.IndexConstants;
import net.osmand.data.LatLon;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
Expand Down Expand Up @@ -351,7 +352,6 @@ protected String getSortEntryName() {
@Override
public void setTracksSortMode(@NonNull TracksSortMode sortMode, boolean sortSubFolders) {
if (sortSubFolders) {
removeSurplusTabsSortModes();
sortSubFolder(sortMode);
} else {
Map<String, String> tabsSortModes = settings.getTrackSortModes();
Expand Down Expand Up @@ -382,8 +382,10 @@ private void sortFolders(TrackFolder trackFolder, Map<String, String> tabsSortMo
}

private void removeSurplusTabsSortModes() {
// TODO: Find adequate places to call this from
// Call only from tracks root folder to not lose valid entries!
if (!rootFolder.getDirFile().equals(app.getAppPath(IndexConstants.GPX_INDEX_DIR))) {
// Execute only from tracks root folder to not lose valid entries
return;
}
OsmandSettings settings = app.getSettings();
Map<String, String> oldTabsSortModes = settings.getTrackSortModes();
Map<String, String> tabsSortModes = new HashMap<>();
Expand Down Expand Up @@ -508,11 +510,13 @@ public ScreenPositionData getFirstSuitableItemScreenPosition() {
@Override
public void onFolderRenamed(@NonNull File newDir) {
updateContent();
removeSurplusTabsSortModes();
}

@Override
public void onFolderDeleted() {
reloadTracks();
removeSurplusTabsSortModes();
}

@Override
Expand Down

0 comments on commit a226f58

Please sign in to comment.