MapWithAILayerInfo: Sort all entries

Signed-off-by: Taylor Smock <tsmock@fb.com>
pull/1/head
Taylor Smock 2021-07-20 14:12:49 -06:00
rodzic a4ab60cbe3
commit f9308da42f
2 zmienionych plików z 8 dodań i 10 usunięć

Wyświetl plik

@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -23,6 +24,7 @@ import java.util.stream.Collectors;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import org.openstreetmap.gui.jmapviewer.tilesources.TileSourceInfo;
import org.openstreetmap.josm.actions.ExpertToggleAction; import org.openstreetmap.josm.actions.ExpertToggleAction;
import org.openstreetmap.josm.data.Preferences; import org.openstreetmap.josm.data.Preferences;
import org.openstreetmap.josm.data.StructUtils; import org.openstreetmap.josm.data.StructUtils;
@ -342,10 +344,12 @@ public class MapWithAILayerInfo {
allDefaultLayers.clear(); allDefaultLayers.clear();
defaultLayers.addAll(newLayers); defaultLayers.addAll(newLayers);
this.updateEsriLayers(newLayers); this.updateEsriLayers(newLayers);
allDefaultLayers.sort(new MapWithAIInfo.MapWithAIInfoCategoryComparator());
allDefaultLayers.sort(Comparator.comparing(TileSourceInfo::getName));
allDefaultLayers.sort(Comparator.comparing(info -> info.getCategory().getDescription()));
allDefaultLayers.sort(Comparator
.comparingInt(info -> (-1) * info.getAdditionalCategories().indexOf(MapWithAICategory.FEATURED)));
defaultLayerIds.clear(); defaultLayerIds.clear();
Collections.sort(defaultLayers, new MapWithAIInfo.MapWithAIInfoCategoryComparator());
Collections.sort(allDefaultLayers, new MapWithAIInfo.MapWithAIInfoCategoryComparator());
buildIdMap(allDefaultLayers, defaultLayerIds); buildIdMap(allDefaultLayers, defaultLayerIds);
updateEntriesFromDefaults(!loadError); updateEntriesFromDefaults(!loadError);
buildIdMap(layers, layerIds); buildIdMap(layers, layerIds);

Wyświetl plik

@ -8,7 +8,6 @@ import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -32,7 +31,6 @@ import javax.json.JsonStructure;
import javax.json.JsonValue; import javax.json.JsonValue;
import javax.json.stream.JsonParsingException; import javax.json.stream.JsonParsingException;
import org.openstreetmap.gui.jmapviewer.tilesources.TileSourceInfo;
import org.openstreetmap.josm.data.cache.JCSCacheManager; import org.openstreetmap.josm.data.cache.JCSCacheManager;
import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryBounds; import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryBounds;
import org.openstreetmap.josm.data.preferences.LongProperty; import org.openstreetmap.josm.data.preferences.LongProperty;
@ -145,11 +143,7 @@ public class ESRISourceReader {
Logging.warn(e); Logging.warn(e);
} }
} }
return information.stream().sorted(Comparator.comparing(TileSourceInfo::getName)) return information;
.sorted(Comparator.comparing(info -> info.getCategory().getDescription()))
.sorted(Comparator.comparingInt(
info -> (-1) * info.getAdditionalCategories().indexOf(MapWithAICategory.FEATURED)))
.collect(Collectors.toList());
} }
/** /**