From 42957a1aa2ebebd0a36043d21c2d66f585eb8706 Mon Sep 17 00:00:00 2001
From: Alex Ning <chineseperson5@gmail.com>
Date: Mon, 7 Dec 2020 21:52:51 +0800
Subject: Fix crash when parsing post with null readPostList value.

---
 .../java/ml/docilealligator/infinityforreddit/post/ParsePost.java  | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'app/src')

diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
index abf046af..e4a7303c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
@@ -568,14 +568,17 @@ public class ParsePost {
                     size = nPosts;
                 }
 
-                HashSet<ReadPost> readPostHashSet = new HashSet<>(readPostList);
+                HashSet<ReadPost> readPostHashSet = null;
+                if (readPostList != null) {
+                    readPostHashSet = new HashSet<>(readPostList);
+                }
                 for (int i = 0; i < size; i++) {
                     try {
                         if (allData.getJSONObject(i).getString(JSONUtils.KIND_KEY).equals("t3")) {
                             JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
                             Post post = parseBasicData(data);
                             boolean availablePost = true;
-                            if (readPostHashSet.contains(ReadPost.convertPost(post))) {
+                            if (readPostHashSet != null && readPostHashSet.contains(ReadPost.convertPost(post))) {
                                 post.markAsRead();
                             }
                             if (subredditFilterList != null) {
-- 
cgit v1.2.3