From ed738437e651057b4cde959593cc0505eef401f4 Mon Sep 17 00:00:00 2001 From: scria1000 <91804886+scria1000@users.noreply.github.com> Date: Tue, 24 Jan 2023 15:53:36 +0000 Subject: [PATCH] Additional checks for null or potentially empty array (#1341) --- .../adapters/PostGalleryTypeImageRecyclerViewAdapter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java index 41b00634..16447653 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java @@ -118,7 +118,7 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte } private void loadImage(ImageViewHolder holder) { - if (galleryImages == null) { + if (galleryImages == null || galleryImages.isEmpty()) { return; } @@ -146,6 +146,10 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte } private void loadCaptionPreview(ImageViewHolder holder) { + if (galleryImages == null || galleryImages.isEmpty()) { + return; + } + String previewCaption = galleryImages.get(holder.getBindingAdapterPosition()).caption; String previewCaptionUrl = galleryImages.get(holder.getBindingAdapterPosition()).captionUrl; boolean previewCaptionIsEmpty = TextUtils.isEmpty(previewCaption);