CV == 0 means none recommended. No CV declared means latest compatible apk recommended.

This commit is contained in:
Daniel Martí 2013-07-23 18:19:04 +02:00
parent 0c1b854b69
commit 03ca3e0e05
2 changed files with 25 additions and 15 deletions

View File

@ -191,20 +191,14 @@ public class DB {
// most recent, if for example there are betas etc.
public Apk getCurrentVersion() {
// Try and return the real current version first...
// Try and return the real current version first. It will find the
// closest version smaller than the curVercode, being the same
// vercode if it exists.
if (curVercode > 0) {
for (Apk apk : apks) {
if (apk.compatible && apk.vercode == curVercode)
return apk;
}
}
// If we don't know the current version, or we don't have it, we
// return the most recent version we have...
int latestcode = -1;
Apk latestapk = null;
for (Apk apk : apks) {
if (apk.compatible &&apk.vercode < curVercode
if (apk.compatible && apk.vercode <= curVercode
&& apk.vercode > latestcode) {
latestapk = apk;
latestcode = apk.vercode;
@ -213,6 +207,22 @@ public class DB {
return latestapk;
}
// If the current version was not set we return the most recent apk.
if (curVercode == -1) {
int latestcode = -1;
Apk latestapk = null;
for (Apk apk : apks) {
if (apk.compatible && apk.vercode > latestcode) {
latestapk = apk;
latestcode = apk.vercode;
}
}
return latestapk;
}
return null;
}
@Override
public int compareTo(App arg0) {
return name.compareToIgnoreCase(arg0.name);

View File

@ -137,7 +137,7 @@ public class RepoXMLHandler extends DefaultHandler {
try {
curapk.vercode = Integer.parseInt(str);
} catch (NumberFormatException ex) {
curapk.vercode = 0;
curapk.vercode = -1;
}
} else if (curel.equals("size")) {
try {
@ -228,7 +228,7 @@ public class RepoXMLHandler extends DefaultHandler {
try {
curapp.curVercode = Integer.parseInt(str);
} catch (NumberFormatException ex) {
curapp.curVercode = 0;
curapp.curVercode = -1;
}
} else if (curel.equals("antifeatures")) {
curapp.antiFeatures = DB.CommaSeparatedList.make(str);