Skip to content

Commit

Permalink
Merge pull request #21520 from osmandapp/FixCrashAfterRemoveFolder
Browse files Browse the repository at this point in the history
Fix crash after remove Tracks Folder
  • Loading branch information
Chumva authored Dec 4, 2024
2 parents ead9446 + 938cfcc commit a249ace
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ public TracksSortMode getSortMode(@NonNull String id) {

public void setSortMode(@NonNull String id, @Nullable TracksSortMode sortMode) {
id = removeExtraFileSeparator(id);
cachedSortModes.put(id, sortMode);
if (sortMode != null) {
cachedSortModes.put(id, sortMode);
} else {
cachedSortModes.remove(id);
}
}

public void setSortModes(@NonNull Map<String, TracksSortMode> sortModes) {
Expand Down Expand Up @@ -97,9 +101,7 @@ private void saveToPreference() {
List<String> tokens = new ArrayList<>();
for (Entry<String, TracksSortMode> entry : cachedSortModes.entrySet()) {
TracksSortMode value = entry.getValue();
if (value != null) {
tokens.add(entry.getKey() + SEPARATOR + value.name());
}
tokens.add(entry.getKey() + SEPARATOR + value.name());
}
preference.setStringsList(tokens);
}
Expand Down

0 comments on commit a249ace

Please sign in to comment.