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:
parent
f388f32fcf
commit
3ad429aa6b
@ -1,6 +1,7 @@
|
|||||||
package org.fdroid.fdroid.views.swap;
|
package org.fdroid.fdroid.views.swap;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -330,10 +331,13 @@ public class SwapAppsView extends ListView implements
|
|||||||
private final ContentObserver appObserver = new ContentObserver(new Handler()) {
|
private final ContentObserver appObserver = new ContentObserver(new Handler()) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange) {
|
public void onChange(boolean selfChange) {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity != null) {
|
||||||
app = AppProvider.Helper.findById(getActivity().getContentResolver(), app.id);
|
app = AppProvider.Helper.findById(getActivity().getContentResolver(), app.id);
|
||||||
apkToInstall = null; // Force lazy loading to fetch correct apk next time.
|
apkToInstall = null; // Force lazy loading to fetch correct apk next time.
|
||||||
resetView();
|
resetView();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public ViewHolder() {
|
public ViewHolder() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user