From 9ae02ddb151a98815ce5950525b8a37ce42c5613 Mon Sep 17 00:00:00 2001 From: hritikRitss <113812066+hritikRitss@users.noreply.github.com> Date: Fri, 26 Sep 2025 23:47:37 +0530 Subject: [PATCH] fix: reset mainImageIndex if it exceeds available image count --- .../java/protect/card_locker/LoyaltyCardViewActivity.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index 35c067362..705b4a515 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -1085,6 +1085,12 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements } private void setMainImagePreviousNextButtons() { + // Ensure the main image index is valid. After a card update, some images (front/back/barcode) + // may have been removed, so the index should not exceed the number of available images. + if(mainImageIndex > imageTypes.size() - 1){ + mainImageIndex = 0; + } + if (imageTypes.size() < 2) { binding.mainLeftButton.setVisibility(View.INVISIBLE); binding.mainRightButton.setVisibility(View.INVISIBLE);