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

View File

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