Resolved a crash, under some circumstances, after installing an app and returning

This commit is contained in:
Ciaran Gultnieks 2010-12-09 10:57:28 +00:00
parent b9a41878f8
commit 38fc4bfec1
2 changed files with 20 additions and 9 deletions

View File

@ -162,6 +162,7 @@ public class AppDetails extends ListActivity {
}
private boolean pref_cacheDownloaded;
private boolean viewResetRequired;
@Override
protected void onStart() {
@ -173,24 +174,33 @@ public class AppDetails extends ListActivity {
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
pref_cacheDownloaded = prefs.getBoolean("cacheDownloaded", true);
viewResetRequired = true;
reset(false);
}
@Override
protected void onResume() {
if (viewResetRequired) {
reset();
viewResetRequired = false;
}
super.onResume();
}
@Override
protected void onStop() {
db.close();
db = null;
((FDroidApp) getApplication()).inActivity--;
super.onStop();
}
// Reset the display and list contents. Used when entering the activity, and
// also when something has been installed/uninstalled. In the latter case,
// 'update' is true to make the installed status get refreshed.
private void reset(boolean update) {
// also when something has been installed/uninstalled.
private void reset() {
Log.d("FDroid", "Getting application details for " + appid);
app = db.getApps(appid, null, update).get(0);
app = db.getApps(appid, null, true).get(0);
DB.Apk curver = app.getCurrentVersion();
app_currentvercode = curver == null ? 0 : curver.vercode;
@ -540,6 +550,7 @@ public class AppDetails extends ListActivity {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_INSTALL) {
// If we're not meant to be caching, delete the apk file we just
// installed (or maybe the user cancelled the install - doesn't
@ -551,9 +562,10 @@ public class AppDetails extends ListActivity {
File file = new File(apk_file);
file.delete();
}
viewResetRequired = true;
}
reset(true);
}
}

View File

@ -347,9 +347,9 @@ public class DB {
// version is older than the current one.
for (App app : result) {
Apk curver = app.getCurrentVersion();
if (curver!= null && app.installedVersion != null
if (curver != null && app.installedVersion != null
&& !app.installedVersion.equals(curver.version)) {
if(app.installedVerCode < curver.vercode)
if (app.installedVerCode < curver.vercode)
app.hasUpdates = true;
}
}
@ -363,7 +363,6 @@ public class DB {
Map<String, PackageInfo> systemApks = new HashMap<String, PackageInfo>();
Log.d("FDroid", "Reading installed packages");
for (PackageInfo appInfo : installedPackages) {
Log.d("FDroid", "... " + appInfo.packageName);
systemApks.put(appInfo.packageName, appInfo);
}