Further fixes
This commit is contained in:
parent
95ca923431
commit
3cf5085a00
1 changed files with 22 additions and 41 deletions
|
@ -2,6 +2,7 @@ package net.osmand.util;
|
|||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
@ -113,56 +114,36 @@ public class Algorithms {
|
|||
return -simplifyFileName(o1.getName()).compareTo(simplifyFileName(o2.getName()));
|
||||
}
|
||||
|
||||
public String simplifyFileName(String fn) {
|
||||
String lc = fn.toLowerCase();
|
||||
if (lc.contains(".")) {
|
||||
lc = lc.substring(0, lc.indexOf("."));
|
||||
}
|
||||
if (lc.endsWith("_2")) {
|
||||
lc = lc.substring(0, lc.length() - "_2".length());
|
||||
}
|
||||
boolean hasTimestampEnd = false;
|
||||
for (int i = 0; i < lc.length(); i++) {
|
||||
if (lc.charAt(i) >= '0' && lc.charAt(i) <= '9') {
|
||||
hasTimestampEnd = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasTimestampEnd) {
|
||||
lc += "_00_00_00";
|
||||
}
|
||||
return lc;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static String simplifyFileName(String fn) {
|
||||
String lc = fn.toLowerCase();
|
||||
if (lc.contains(".")) {
|
||||
lc = lc.substring(0, lc.indexOf("."));
|
||||
}
|
||||
if (lc.endsWith("_2")) {
|
||||
lc = lc.substring(0, lc.length() - "_2".length());
|
||||
}
|
||||
boolean hasTimestampEnd = false;
|
||||
for (int i = 0; i < lc.length(); i++) {
|
||||
if (lc.charAt(i) >= '0' && lc.charAt(i) <= '9') {
|
||||
hasTimestampEnd = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasTimestampEnd) {
|
||||
lc += "_00_00_00";
|
||||
}
|
||||
return lc;
|
||||
}
|
||||
|
||||
public static Comparator<String> getStringVersionComparator() {
|
||||
return new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
return -simplifyFileName(o1).compareTo(simplifyFileName(o2));
|
||||
}
|
||||
|
||||
public String simplifyFileName(String fn) {
|
||||
String lc = fn.toLowerCase();
|
||||
if (lc.contains(".")) {
|
||||
lc = lc.substring(0, lc.indexOf("."));
|
||||
}
|
||||
if (lc.endsWith("_2")) {
|
||||
lc = lc.substring(0, lc.length() - "_2".length());
|
||||
}
|
||||
boolean hasTimestampEnd = false;
|
||||
for (int i = 0; i < lc.length(); i++) {
|
||||
if (lc.charAt(i) >= '0' && lc.charAt(i) <= '9') {
|
||||
hasTimestampEnd = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasTimestampEnd) {
|
||||
lc += "_00_00_00";
|
||||
}
|
||||
return lc;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue