From d37b473e10bdc4e138a65876046ff8167ee5fff3 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 16 Sep 2015 12:33:17 +0200 Subject: [PATCH] temporary workaround to NPE crash on first install The solution is really to get rid of the Fragment and do everything in the Activity, especially since this nullguard will probably leave things in a not good state. But that's better than a crash, I think. W java.lang.NullPointerException W at org.fdroid.fdroid.views.fragments.AvailableAppsFragment$CategoryObserver.onChange(AvailableAppsFragment.java:88) W at org.fdroid.fdroid.views.fragments.AvailableAppsFragment$CategoryObserver.onChange(AvailableAppsFragment.java:103) W at android.database.ContentObserver.dispatchChange(ContentObserver.java:163) W at android.database.ContentObserver$Transport.onChange(ContentObserver.java:195) W at android.database.IContentObserver$Stub.onTransact(IContentObserver.java:60) W at android.os.Binder.execTransact(Binder.java:404) W at dalvik.system.NativeStart.run(Native Method) --- .../fdroid/views/fragments/AvailableAppsFragment.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/F-Droid/src/org/fdroid/fdroid/views/fragments/AvailableAppsFragment.java b/F-Droid/src/org/fdroid/fdroid/views/fragments/AvailableAppsFragment.java index 8b907f510..8ce67a395 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/fragments/AvailableAppsFragment.java +++ b/F-Droid/src/org/fdroid/fdroid/views/fragments/AvailableAppsFragment.java @@ -84,7 +84,11 @@ public class AvailableAppsFragment extends AppListFragment implements // Wanted to just do this update here, but android tells // me that "Only the original thread that created a view // hierarchy can touch its views." - getActivity().runOnUiThread(new Runnable() { + final Activity activity = getActivity(); + // this nullguard is temporary, this Fragment really needs to merged into the Activity + if (activity == null) + return; + activity.runOnUiThread(new Runnable() { @Override public void run() { if (adapter == null) {