From eef1e0a406c2f5879a62be281334878cc17afc22 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 13 Mar 2015 10:37:57 +0100 Subject: [PATCH] Externalize application changed actions When we receive notifications indicating that the app has changed, the App object needs to be changed and the view updated. These notifications can be received from two sources: - the ContentObserver; - onActivityResult(). Thus, the implementation should not be related to the ContentObserver (in theory, we might want to keep only the onActivityResult() notification). Therefore, move it to a separate method in AppDetails. This also preventively avoids bugs when the ContentObserver is null. --- F-Droid/src/org/fdroid/fdroid/AppDetails.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/F-Droid/src/org/fdroid/fdroid/AppDetails.java b/F-Droid/src/org/fdroid/fdroid/AppDetails.java index 106115846..1f51f12d4 100644 --- a/F-Droid/src/org/fdroid/fdroid/AppDetails.java +++ b/F-Droid/src/org/fdroid/fdroid/AppDetails.java @@ -144,18 +144,9 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A @Override public void onChange(boolean selfChange, Uri uri) { - onChange(); + onAppChanged(); } - public void onChange() { - if (!reset(app.id)) { - AppDetails.this.finish(); - return; - } - - refreshApkList(); - supportInvalidateOptionsMenu(); - } } class ApkListAdapter extends ArrayAdapter { @@ -546,6 +537,16 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A removeProgressDialog(); } + private void onAppChanged() { + if (!reset(app.id)) { + AppDetails.this.finish(); + return; + } + + refreshApkList(); + supportInvalidateOptionsMenu(); + } + public void setIgnoreUpdates(String appId, boolean ignoreAll, int ignoreVersionCode) { Uri uri = AppProvider.getContentUri(appId); @@ -929,7 +930,7 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A } setSupportProgressBarIndeterminateVisibility(false); - myAppObserver.onChange(); + onAppChanged(); } }); } @@ -941,7 +942,7 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A @Override public void run() { setSupportProgressBarIndeterminateVisibility(false); - myAppObserver.onChange(); + onAppChanged(); } }); } else { @@ -949,7 +950,7 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A @Override public void run() { setSupportProgressBarIndeterminateVisibility(false); - myAppObserver.onChange(); + onAppChanged(); Log.e(TAG, "Installer aborted with errorCode: " + errorCode);