TP-55650 | round off savings experiment change (#9573)

This commit is contained in:
Apoorv Nigam
2024-01-31 13:45:04 +05:30
committed by GitHub
parent 7eeb332ca1
commit 3065e31c31
3 changed files with 6 additions and 1 deletions

View File

@@ -46,4 +46,5 @@ interface GoldConversionWidgetInfo {
fun textIconCode() : String?
fun textLottieCode() : String?
fun dynamicText(): DynamicText?
fun isRoundOffSavingsEnabled(): Boolean?
}

View File

@@ -98,6 +98,7 @@ data class GoldConversionWidget(
override fun textIconCode(): String? = widgetData?.textIconCode
override fun textLottieCode(): String? = widgetData?.textLottieCode
override fun dynamicText(): DynamicText? = widgetData?.dynamicText
override fun isRoundOffSavingsEnabled(): Boolean? = widgetData?.isRoundOffSavingsEnabled
}
data class GoldConversionData(
@@ -152,6 +153,8 @@ data class GoldConversionData(
val textLottieCode: String? = null,
@SerializedName("dynamicText")
val dynamicText: DynamicText? = null,
@SerializedName("isRoundOffSavingsEnabled")
val isRoundOffSavingsEnabled: Boolean? = false
) : Serializable
data class AmountConstraint(

View File

@@ -99,6 +99,7 @@ class GoldConversionWidgetLayout @JvmOverloads constructor(
private const val KEY_COLOR_SELECTED = "selected"
private const val DEFAULT_COLOR_VARIATION_SELECTED = "#1F002A"
private const val DEFAULT_COLOR_VARIATION_UNSELECTED = "#EBEBEB"
private const val PRECISION_THRESHOLD = 0.000001
}
fun update(
@@ -647,7 +648,7 @@ class GoldConversionWidgetLayout @JvmOverloads constructor(
private fun decimalFormatOfWeight(weight: Double, roundDown: Boolean = true) =
when (unitOfGold) {
context.getString(R.string.milligram_unit) -> {
if(weight < 0.2 || !roundDown) {
if((weight - 0.2 < PRECISION_THRESHOLD && info.isRoundOffSavingsEnabled().orFalse()) || !roundDown) {
decimalFormatWithOneDecimal.roundingMode = RoundingMode.UP
}
else decimalFormatWithOneDecimal.roundingMode = RoundingMode.DOWN