Browse Source

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)
...
```
renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
committed by GitHub
parent
commit
23b7119846
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java

6
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() { 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) { private boolean isSafeToNavigate(final NavController navController) {

Loading…
Cancel
Save