Only cleanup receivers, don't reset the UI when in onDestroy().

When an Activity is destroyed, the next time it is created should
reinitialize all of the UI stuff again. Thus, there is no point to
clearing up the UI state before leaving. More importantly, this was
causing a problem when navigating back and forth through activities
via the downloader service notifications:

```
E  java.lang.RuntimeException: Unable to destroy activity {org.fdroid.fdroid/org.fdroid.fdroid.AppDetails}: java.lang.IllegalStateException: activity is already destroyed
...
E  Caused by: java.lang.IllegalStateException: activity is already destroyed
E      at android.nfc.NfcActivityManager$NfcActivityState.<init>(NfcActivityManager.java:126)
E      at android.nfc.NfcActivityManager.getActivityState(NfcActivityManager.java:176)
E      at android.nfc.NfcActivityManager.setNdefPushContentUri(NfcActivityManager.java:252)
E      at android.nfc.NfcAdapter.setBeamPushUris(NfcAdapter.java:830)
E      at org.fdroid.fdroid.NfcHelper.disableAndroidBeam(NfcHelper.java:68)
E      at org.fdroid.fdroid.AppDetails$AppDetailsHeaderFragment.updateViews(AppDetails.java:1507)
E      at org.fdroid.fdroid.AppDetails$AppDetailsHeaderFragment.updateViews(AppDetails.java:1490)
E      at org.fdroid.fdroid.AppDetails$AppDetailsHeaderFragment.removeProgress(AppDetails.java:1473)
E      at org.fdroid.fdroid.AppDetails.cleanUpFinishedDownload(AppDetails.java:442)
E      at org.fdroid.fdroid.AppDetails.onDestroy(AppDetails.java:567)
E      at android.app.Activity.performDestroy(Activity.java:6169)
E      at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1141)
E      at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3726)
E      ... 10 more
```

This is related to `onDestroy` calling a method which ends up calling
UI related stuff that assumes the `Activity` is around to interact with.
This commit is contained in:
Peter Serwylo 2016-04-21 13:51:16 +10:00
parent 8794611b26
commit e56d604d6f

View File

@ -564,7 +564,7 @@ public class AppDetails extends AppCompatActivity {
@Override @Override
protected void onDestroy() { protected void onDestroy() {
cleanUpFinishedDownload(); unregisterDownloaderReceivers();
super.onDestroy(); super.onDestroy();
} }