From 23b711984690ee33ca52d1a9183d434972aba01f Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sat, 15 May 2021 20:40:02 -0400 Subject: [PATCH] null check to avoid launch crash immediately hitting the feed tab after launch will produce the following crash, so this resolves it by a null check: ``` java.lang.NullPointerException: Attempt to read from field 'awais.instagrabber.customviews.PostsRecyclerView awais.instagrabber.databinding.FragmentFeedBinding.feedRecyclerView' on a null object reference at awais.instagrabber.fragments.main.FeedFragment.scrollToTop(FeedFragment.java:461) at awais.instagrabber.utils.NavigationExtensions.lambda$setupItemReselected$2(NavigationExtensions.java:190) at awais.instagrabber.utils.-$$Lambda$NavigationExtensions$C3II1R-NOFB80ERAxio06uf3Qto.onNavigationItemReselected(Unknown Source:4) ... ``` --- .../awais/instagrabber/fragments/main/FeedFragment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java b/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java index f068f069..d22b5a51 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java @@ -458,8 +458,10 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre } public void scrollToTop() { - binding.feedRecyclerView.smoothScrollToPosition(0); - // binding.storiesContainer.setExpanded(true); + if (binding != null) { + binding.feedRecyclerView.smoothScrollToPosition(0); + // binding.storiesContainer.setExpanded(true); + } } private boolean isSafeToNavigate(final NavController navController) {