ANDROID: Avoid crash if version no is not int
This can happen during development - shouldn't happen for any official release, but even if it does let's just assume versions are different and default to upgrading the config.
This commit is contained in:
parent
16a105cdbb
commit
e1bff1cbb3
1 changed files with 13 additions and 9 deletions
|
@ -36,15 +36,19 @@ public class Version implements Comparable<Version> {
|
|||
String[] thisParts = this.get().split("\\.");
|
||||
String[] thatParts = that.get().split("\\.");
|
||||
int length = Math.max(thisParts.length, thatParts.length);
|
||||
for(int i = 0; i < length; i++) {
|
||||
int thisPart = i < thisParts.length ?
|
||||
Integer.parseInt(thisParts[i]) : 0;
|
||||
int thatPart = i < thatParts.length ?
|
||||
Integer.parseInt(thatParts[i]) : 0;
|
||||
if(thisPart < thatPart)
|
||||
return -1;
|
||||
if(thisPart > thatPart)
|
||||
return 1;
|
||||
try {
|
||||
for (int i = 0; i < length; i++) {
|
||||
int thisPart = i < thisParts.length ?
|
||||
Integer.parseInt(thisParts[i]) : 0;
|
||||
int thatPart = i < thatParts.length ?
|
||||
Integer.parseInt(thatParts[i]) : 0;
|
||||
if (thisPart < thatPart)
|
||||
return -1;
|
||||
if (thisPart > thatPart)
|
||||
return 1;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue