From 82f1140cbf43fa1f7049ff78089a184196fbab88 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Mon, 12 Jul 2021 22:19:33 +0900 Subject: [PATCH] Null check. Fixes austinhuang0131/barinsta#1629 --- .../instagrabber/fragments/LikesViewerFragment.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/LikesViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/LikesViewerFragment.java index bbf97bd6..c4330b8e 100644 --- a/app/src/main/java/awais/instagrabber/fragments/LikesViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/LikesViewerFragment.java @@ -64,8 +64,10 @@ public final class LikesViewerFragment extends BottomSheetDialogFragment impleme } }); binding.rvLikes.setAdapter(likesAdapter); - binding.rvLikes.setLayoutManager(new LinearLayoutManager(getContext())); - binding.rvLikes.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL)); + final Context context = getContext(); + if (context == null) return; + binding.rvLikes.setLayoutManager(new LinearLayoutManager(context)); + binding.rvLikes.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); binding.swipeRefreshLayout.setRefreshing(false); } @@ -176,9 +178,11 @@ public final class LikesViewerFragment extends BottomSheetDialogFragment impleme binding.swipeRefreshLayout.setOnRefreshListener(this); binding.swipeRefreshLayout.setRefreshing(true); if (isComment && !isLoggedIn) { - final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); + final Context context = getContext(); + if (context == null) return; + final LinearLayoutManager layoutManager = new LinearLayoutManager(context); binding.rvLikes.setLayoutManager(layoutManager); - binding.rvLikes.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.HORIZONTAL)); + binding.rvLikes.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.HORIZONTAL)); lazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> { if (!TextUtils.isEmpty(endCursor)) { graphQLRepository.fetchCommentLikers(