From 7ca0d513dca8869f13d194a0c6e651e8da2ba0bd Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Sun, 23 May 2021 17:11:12 +0900 Subject: [PATCH] Null check --- .../adapters/viewholder/FeedGridItemViewHolder.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/FeedGridItemViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/FeedGridItemViewHolder.java index d31abf8a..af869af1 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/FeedGridItemViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/FeedGridItemViewHolder.java @@ -21,6 +21,7 @@ import awais.instagrabber.R; import awais.instagrabber.adapters.FeedAdapterV2; import awais.instagrabber.databinding.ItemFeedGridBinding; import awais.instagrabber.models.PostsLayoutPreferences; +import awais.instagrabber.models.enums.MediaItemType; import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.User; import awais.instagrabber.utils.DownloadUtils; @@ -68,7 +69,9 @@ public class FeedGridItemViewHolder extends RecyclerView.ViewHolder { setUserDetails(media, layoutPreferences); String thumbnailUrl = null; final int typeIconRes; - switch (media.getMediaType()) { + final MediaItemType mediaType = media.getMediaType(); + if (mediaType == null) return; + switch (mediaType) { case MEDIA_TYPE_IMAGE: typeIconRes = -1; thumbnailUrl = ResponseBodyUtils.getThumbUrl(media); @@ -103,7 +106,7 @@ public class FeedGridItemViewHolder extends RecyclerView.ViewHolder { binding.typeIcon.setImageResource(typeIconRes); } final List checkList = DownloadUtils.checkDownloaded(media); - if (checkList == null || checkList.isEmpty()) { + if (checkList.isEmpty()) { return; } switch (media.getMediaType()) {