From 977ccce22c04693599ea45a06b94ff3a6950a677 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Fri, 9 Apr 2021 19:57:56 +0900 Subject: [PATCH] Null checks. Fixes https://github.com/austinhuang0131/barinsta/issues/990 --- .../directmessages/DirectMessageThreadFragment.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java b/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java index 57f17cf2..73bf0244 100644 --- a/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java @@ -414,10 +414,14 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact case SUCCESS: Toast.makeText(context, R.string.marked_as_seen, Toast.LENGTH_SHORT).show(); case LOADING: - item.setEnabled(false); + if (item != null) { + item.setEnabled(false); + } break; case ERROR: - item.setEnabled(true); + if (item != null) { + item.setEnabled(true); + } if (resource.message != null) { Snackbar.make(context, binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show(); return; @@ -956,7 +960,9 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact } final DirectThread thread = threadLiveData.getValue(); if (thread == null) return; - markAsSeenMenuItem.setEnabled(!DMUtils.isRead(thread)); + if (markAsSeenMenuItem != null) { + markAsSeenMenuItem.setEnabled(!DMUtils.isRead(thread)); + } }); if (itemsAdapter == null) return; itemsAdapter.submitList(items, () -> {