Guard against null activity.

Came across this whibluetooth swap.
I think it is reasonable to guard against null activities here, because
we are likely not releasing observers correctly, and thus the observer
may receieve a notification when the activity is not attached.
This commit is contained in:
Peter Serwylo 2015-10-10 08:52:14 +11:00
parent f388f32fcf
commit 3ad429aa6b

View File

@ -1,6 +1,7 @@
package org.fdroid.fdroid.views.swap;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@ -330,9 +331,12 @@ public class SwapAppsView extends ListView implements
private final ContentObserver appObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
app = AppProvider.Helper.findById(getActivity().getContentResolver(), app.id);
apkToInstall = null; // Force lazy loading to fetch correct apk next time.
resetView();
Activity activity = getActivity();
if (activity != null) {
app = AppProvider.Helper.findById(getActivity().getContentResolver(), app.id);
apkToInstall = null; // Force lazy loading to fetch correct apk next time.
resetView();
}
}
};