From b3d41ccffa75e80dddfcb674280c24df2f48c1fb Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Sun, 15 Nov 2020 21:55:07 +0900 Subject: [PATCH] Some null checks. Fixes https://github.com/austinhuang0131/barinsta/issues/274 --- .../java/awais/instagrabber/fragments/HashTagFragment.java | 3 ++- .../java/awais/instagrabber/fragments/LocationFragment.java | 3 ++- .../awais/instagrabber/fragments/main/DiscoverFragment.java | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java b/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java index 9681de1a..593e5750 100644 --- a/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java @@ -200,7 +200,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe Utils.openEmailAddress(getContext(), emailId); } - private void openPostDialog(final FeedModel feedModel, + private void openPostDialog(@NonNull final FeedModel feedModel, final View profilePicView, final View mainPostImage, final int position) { @@ -209,6 +209,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe opening = true; new PostFetcher(feedModel.getShortCode(), newFeedModel -> { opening = false; + if (newFeedModel == null) return; openPostDialog(newFeedModel, profilePicView, mainPostImage, position); }).execute(); return; diff --git a/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java b/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java index ef21d431..c66543fc 100644 --- a/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java @@ -198,7 +198,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR Utils.openEmailAddress(getContext(), emailId); } - private void openPostDialog(final FeedModel feedModel, + private void openPostDialog(@NonNull final FeedModel feedModel, final View profilePicView, final View mainPostImage, final int position) { @@ -207,6 +207,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR opening = true; new PostFetcher(feedModel.getShortCode(), newFeedModel -> { opening = false; + if (newFeedModel == null) return; openPostDialog(newFeedModel, profilePicView, mainPostImage, position); }).execute(); return; diff --git a/app/src/main/java/awais/instagrabber/fragments/main/DiscoverFragment.java b/app/src/main/java/awais/instagrabber/fragments/main/DiscoverFragment.java index 24ccf8ee..adc6fe43 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/DiscoverFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/DiscoverFragment.java @@ -91,6 +91,7 @@ public class DiscoverFragment extends Fragment implements SwipeRefreshLayout.OnR discoverService.topicalExplore(new DiscoverService.TopicalExploreRequest(), new ServiceCallback() { @Override public void onSuccess(final DiscoverService.TopicalExploreResponse result) { + if (result == null) return; topicClusterViewModel.getList().postValue(result.getClusters()); binding.swipeRefreshLayout.setRefreshing(false); }