From 28a9d580fd7c2cf1c73c32133019c1afcca219fa Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Mon, 31 Jul 2017 13:14:43 -0300 Subject: [PATCH] re-arranged if checks to only try getting selected site if fragment is added, then checked for site != null to avoid NPE --- .../wordpress/android/ui/main/MySiteFragment.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/MySiteFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/main/MySiteFragment.java index 2391507d0c1d..598cf1bb2a63 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/MySiteFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/MySiteFragment.java @@ -494,10 +494,14 @@ public void onSiteChanged(OnSiteChanged event) { @Subscribe(threadMode = ThreadMode.MAIN) public void onPostUploaded(PostStore.OnPostUploaded event) { final PostModel post = event.post; - SiteModel site = getSelectedSite(); - if (isAdded() && event.post != null && event.post.getLocalSiteId() == site.getId()) { - UploadUtils.onPostUploadedSnackbarHandler(getActivity(), - getActivity().findViewById(R.id.coordinator), event, site, mDispatcher); + if (isAdded() && event.post != null) { + SiteModel site = getSelectedSite(); + if (site != null) { + if (event.post.getLocalSiteId() == site.getId()) { + UploadUtils.onPostUploadedSnackbarHandler(getActivity(), + getActivity().findViewById(R.id.coordinator), event, site, mDispatcher); + } + } } } }