From 0fd035f46a05eb56c6473bac578b75accf6faa8c Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Wed, 6 Sep 2023 18:00:04 +0530 Subject: [PATCH] TP-40568 | loan repayment options fragment on click crash (#7783) --- .../viewholder/RepaymentOptionLayout.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/navi-widgets/src/main/java/com/navi/naviwidgets/viewholder/RepaymentOptionLayout.kt b/navi-widgets/src/main/java/com/navi/naviwidgets/viewholder/RepaymentOptionLayout.kt index 79b0fe1b73..50f54f78aa 100644 --- a/navi-widgets/src/main/java/com/navi/naviwidgets/viewholder/RepaymentOptionLayout.kt +++ b/navi-widgets/src/main/java/com/navi/naviwidgets/viewholder/RepaymentOptionLayout.kt @@ -29,6 +29,7 @@ import com.navi.base.model.LineItem import com.navi.base.utils.BaseUtils import com.navi.base.utils.isNotNull import com.navi.base.utils.isNotNullAndNotEmpty +import com.navi.base.utils.isNull import com.navi.base.utils.orFalse import com.navi.base.utils.orElse import com.navi.design.font.FontWeightEnum @@ -461,8 +462,8 @@ constructor(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(co setDefaultLabel(this.repaymentOption?.amountInput?.errorMessage?.min) return false } - - if (isValidCustomAmount.not()) { + val amount = originalText.toDoubleOrNull() + if (isValidCustomAmount.not() || amount.isNull()) { setError( this.repaymentOption?.amountInput?.errorMessage?.invalidAmount ?: RepaymentErrorMessage( @@ -477,15 +478,17 @@ constructor(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(co ) return false } - val amount = originalText.toDouble() - if (amount > this.repaymentOption?.amountInput?.maxAmount.orElse(Int.MAX_VALUE)) { + if (amount != null && amount > this.repaymentOption?.amountInput?.maxAmount.orElse(Int.MAX_VALUE)) { setError(this.repaymentOption?.amountInput?.errorMessage?.max) return false - } else if (amount < this.repaymentOption?.amountInput?.minAmount.orElse(Int.MIN_VALUE)) { + } else if (amount != null && amount < this.repaymentOption?.amountInput?.minAmount.orElse( + Int.MIN_VALUE + ) + ) { setError(this.repaymentOption?.amountInput?.errorMessage?.min) return false } - showAmountInWords(amount) + amount?.let { showAmountInWords(it) } return true }