From 7dc9583e51dbb4517196c333e6d41044127d53f0 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Mon, 29 Mar 2021 22:48:55 +0900 Subject: [PATCH] Null checks. Fixes https://github.com/austinhuang0131/barinsta/issues/905 --- .../awais/instagrabber/viewmodels/DirectThreadViewModel.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/awais/instagrabber/viewmodels/DirectThreadViewModel.java b/app/src/main/java/awais/instagrabber/viewmodels/DirectThreadViewModel.java index 1ca3c263..3329d6c8 100644 --- a/app/src/main/java/awais/instagrabber/viewmodels/DirectThreadViewModel.java +++ b/app/src/main/java/awais/instagrabber/viewmodels/DirectThreadViewModel.java @@ -241,6 +241,7 @@ public class DirectThreadViewModel extends AndroidViewModel { if (users != null && users.getValue() != null) { final List userList = users.getValue(); match = userList.stream() + .filter(Objects::nonNull) .filter(user -> user.getPk() == userId) .findFirst() .orElse(null); @@ -250,6 +251,7 @@ public class DirectThreadViewModel extends AndroidViewModel { if (leftUsers != null && leftUsers.getValue() != null) { final List userList = leftUsers.getValue(); match = userList.stream() + .filter(Objects::nonNull) .filter(user -> user.getPk() == userId) .findFirst() .orElse(null);