Fix the update checker

Now it's able to parse x.x.x-type-bxxx and x.x.x-bxxx
This commit is contained in:
TfT_02 2013-03-06 22:20:11 +01:00
parent 91d8cd5da8
commit 80927417f2

View File

@ -43,12 +43,18 @@ public class UpdateChecker {
jo = (JSONObject) jo.get("versions"); jo = (JSONObject) jo.get("versions");
newVersion = (String) jo.get("version"); newVersion = (String) jo.get("version");
String[] oldTokens = version.replaceAll("(?i)(-)(.+?)(-)", "").split("[.]|[b]"); String[] oldTokens = version.replaceAll("(?i)(-)(.+?)(-)", "-").split("[.]|-b");
String[] newTokens = newVersion.replaceAll("(?i)(-)(.+?)(-)", "").split("[.]|[b]"); String[] newTokens = newVersion.replaceAll("(?i)(-)(.+?)(-)", "-").split("[.]|-b");
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
Integer newVer = Integer.parseInt(newTokens[i]); Integer newVer = Integer.parseInt(newTokens[i]);
Integer oldVer = Integer.parseInt(oldTokens[i]); Integer oldVer;
try {
oldVer = Integer.parseInt(oldTokens[i]);
}
catch (NumberFormatException e) {
oldVer = 0;
}
if (oldVer < newVer) { if (oldVer < newVer) {
isr.close(); isr.close();
return true; return true;