From 204eb194ad76be701cdc368ef5f69d4917227948 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 25 Aug 2017 17:10:40 +0900 Subject: [PATCH] Fix NPE if activity is null --- .../nutomic/syncthingandroid/fragments/DeviceListFragment.java | 3 ++- .../nutomic/syncthingandroid/fragments/FolderListFragment.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceListFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceListFragment.java index 90f72fe2..9a237203 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceListFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceListFragment.java @@ -77,7 +77,8 @@ public class DeviceListFragment extends ListFragment implements SyncthingService */ private void updateList() { SyncthingActivity activity = (SyncthingActivity) getActivity(); - if (activity.getApi() == null || !activity.getApi().isConfigLoaded() || getView() == null || activity.isFinishing()) + if (activity == null || activity.getApi() == null || !activity.getApi().isConfigLoaded() || + getView() == null || activity.isFinishing()) return; if (mAdapter == null) { diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderListFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderListFragment.java index f547fde6..37c0d813 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderListFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderListFragment.java @@ -72,7 +72,8 @@ public class FolderListFragment extends ListFragment implements SyncthingService */ private void updateList() { SyncthingActivity activity = (SyncthingActivity) getActivity(); - if (activity.getApi() == null || !activity.getApi().isConfigLoaded() || getView() == null || activity.isFinishing()) + if (activity == null || activity.getApi() == null || !activity.getApi().isConfigLoaded() || + getView() == null || activity.isFinishing()) return; if (mAdapter == null) {