From e88c2e957bd5ba6cd703e05d5aa86c19ef049039 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Mon, 6 Feb 2023 13:53:21 -0500 Subject: Version 5.4.0. Minor bugs fixed in PostGalleryTypeImageRecyclerViewAdapter. --- .../adapters/PostGalleryTypeImageRecyclerViewAdapter.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'app/src') 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 02ff29ce..f5ec7c13 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java @@ -123,8 +123,12 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte if (galleryImages == null || galleryImages.isEmpty()) { return; } + int index = holder.getBindingAdapterPosition(); + if (index < 0 || index >= galleryImages.size()) { + return; + } - RequestBuilder imageRequestBuilder = glide.load(galleryImages.get(holder.getBindingAdapterPosition()).url).listener(new RequestListener<>() { + RequestBuilder imageRequestBuilder = glide.load(galleryImages.get(index).url).listener(new RequestListener<>() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { holder.binding.progressBarItemGalleryImageInPostFeed.setVisibility(View.GONE); @@ -152,8 +156,13 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte return; } - String previewCaption = galleryImages.get(holder.getBindingAdapterPosition()).caption; - String previewCaptionUrl = galleryImages.get(holder.getBindingAdapterPosition()).captionUrl; + int index = holder.getBindingAdapterPosition(); + if (index < 0 || index >= galleryImages.size()) { + return; + } + + String previewCaption = galleryImages.get(index).caption; + String previewCaptionUrl = galleryImages.get(index).captionUrl; boolean previewCaptionIsEmpty = TextUtils.isEmpty(previewCaption); boolean previewCaptionUrlIsEmpty = TextUtils.isEmpty(previewCaptionUrl); if (!previewCaptionIsEmpty || !previewCaptionUrlIsEmpty) { -- cgit v1.2.3