TP-55650 | round off savings experiment change (#9573)
This commit is contained in:
@@ -46,4 +46,5 @@ interface GoldConversionWidgetInfo {
|
||||
fun textIconCode() : String?
|
||||
fun textLottieCode() : String?
|
||||
fun dynamicText(): DynamicText?
|
||||
fun isRoundOffSavingsEnabled(): Boolean?
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user