From 7a6232c8b66a4466f4ec4b2ce6bca0a9b53775bd Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Wed, 27 Jul 2022 21:37:44 +0200 Subject: [PATCH] Make spotBugs happy --- .../card_locker/LoyaltyCardEditActivity.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java index d16c55678..4a60299e3 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java @@ -864,12 +864,6 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity { updateTempState(LoyaltyCardField.headerColor, Utils.getRandomHeaderColor(this)); } - // It can't be null because we set it in updateTempState but SpotBugs insists it can be - // NP_NULL_ON_SOME_PATH: Possible null pointer dereference - if (tempLoyaltyCard.headerColor != null) { - thumbnail.setOnClickListener(new ChooseCardImage()); - } - // Update from intent if (barcodeType != null) { try { @@ -916,8 +910,15 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity { generateIcon(storeFieldEdit.getText().toString()); - thumbnailEditIcon.setBackgroundColor(Utils.needsDarkForeground(tempLoyaltyCard.headerColor) ? Color.BLACK : Color.WHITE); - thumbnailEditIcon.setColorFilter(Utils.needsDarkForeground(tempLoyaltyCard.headerColor) ? Color.WHITE : Color.BLACK); + // It can't be null because we set it in updateTempState but SpotBugs insists it can be + // NP_NULL_ON_SOME_PATH: Possible null pointer dereference and + // NP_NULL_PARAM_DEREF: Method call passes null for non-null parameter + Integer headerColor = tempLoyaltyCard.headerColor; + if (headerColor != null) { + thumbnail.setOnClickListener(new ChooseCardImage()); + thumbnailEditIcon.setBackgroundColor(Utils.needsDarkForeground(headerColor) ? Color.BLACK : Color.WHITE); + thumbnailEditIcon.setColorFilter(Utils.needsDarkForeground(headerColor) ? Color.WHITE : Color.BLACK); + } onResuming = false; }