Deal more gracefully with apps in the repo that have no packages available

This commit is contained in:
Ciaran Gultnieks 2010-12-08 15:59:06 +00:00
parent 08e4ebaa29
commit b9a41878f8
2 changed files with 8 additions and 5 deletions

View File

@ -99,7 +99,8 @@ public class AppDetails extends ListActivity {
DB.Apk apk = items.get(position);
TextView version = (TextView) v.findViewById(R.id.version);
boolean iscurrent = apk.vercode == app_currentvercode;
version.setText(getString(R.string.version) + " " + apk.version + (iscurrent ? "*" : ""));
version.setText(getString(R.string.version) + " " + apk.version
+ (iscurrent ? "*" : ""));
TextView status = (TextView) v.findViewById(R.id.status);
if (apk.version.equals(app.installedVersion))
status.setText(getString(R.string.inst));
@ -190,7 +191,8 @@ public class AppDetails extends ListActivity {
Log.d("FDroid", "Getting application details for " + appid);
app = db.getApps(appid, null, update).get(0);
app_currentvercode = app.getCurrentVersion().vercode;
DB.Apk curver = app.getCurrentVersion();
app_currentvercode = curver == null ? 0 : curver.vercode;
// Set the icon...
ImageView iv = (ImageView) findViewById(R.id.icon);
@ -289,7 +291,7 @@ public class AppDetails extends ListActivity {
super.onCreateOptionsMenu(menu);
menu.clear();
DB.Apk curver = app.getCurrentVersion();
if (app.installedVersion != null
if (app.installedVersion != null && curver != null
&& !app.installedVersion.equals(curver.version)) {
menu.add(Menu.NONE, INSTALL, 0, R.string.menu_update).setIcon(
android.R.drawable.ic_menu_add);
@ -326,6 +328,7 @@ public class AppDetails extends ListActivity {
case INSTALL:
// Note that this handles updating as well as installing.
curapk = app.getCurrentVersion();
if (curapk != null)
install();
return true;

View File

@ -347,7 +347,7 @@ public class DB {
// version is older than the current one.
for (App app : result) {
Apk curver = app.getCurrentVersion();
if (app.installedVersion != null
if (curver!= null && app.installedVersion != null
&& !app.installedVersion.equals(curver.version)) {
if(app.installedVerCode < curver.vercode)
app.hasUpdates = true;