Sort world regions
This commit is contained in:
parent
15305bb846
commit
48e34264e7
1 changed files with 19 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
||||||
package net.osmand.plus;
|
package net.osmand.plus;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -196,6 +198,14 @@ public class WorldRegion {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Comparator<WorldRegion> nameComparator = new Comparator<WorldRegion>() {
|
||||||
|
@Override
|
||||||
|
public int compare(WorldRegion w1, WorldRegion w2) {
|
||||||
|
return w1.getName().compareTo(w2.getName());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
sortSubregions(this, nameComparator);
|
||||||
|
|
||||||
if (loadedItems.size() > 0) {
|
if (loadedItems.size() > 0) {
|
||||||
LOG.warn("Found orphaned regions: " + loadedItems.size());
|
LOG.warn("Found orphaned regions: " + loadedItems.size());
|
||||||
for (String regionId : loadedItems.keySet()) {
|
for (String regionId : loadedItems.keySet()) {
|
||||||
|
@ -204,6 +214,15 @@ public class WorldRegion {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sortSubregions(WorldRegion region, Comparator<WorldRegion> comparator) {
|
||||||
|
Collections.sort(region.subregions, comparator);
|
||||||
|
for (WorldRegion r : region.subregions) {
|
||||||
|
if (r.subregions.size() > 0) {
|
||||||
|
sortSubregions(r, comparator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static WorldRegion createRegionAs(String regionId, Map<String, String> loadedItems,
|
private static WorldRegion createRegionAs(String regionId, Map<String, String> loadedItems,
|
||||||
OsmandRegions osmandRegions, String localizedName) {
|
OsmandRegions osmandRegions, String localizedName) {
|
||||||
WorldRegion worldRegion = new WorldRegion().init(regionId, osmandRegions, localizedName);
|
WorldRegion worldRegion = new WorldRegion().init(regionId, osmandRegions, localizedName);
|
||||||
|
|
Loading…
Reference in a new issue