|
|
|
@ -16,6 +16,7 @@ import net.pokeranalytics.android.util.toCurrency |
|
|
|
class BottomSheetSumFragment : BottomSheetFragment() { |
|
|
|
class BottomSheetSumFragment : BottomSheetFragment() { |
|
|
|
|
|
|
|
|
|
|
|
private var value = 0.0 |
|
|
|
private var value = 0.0 |
|
|
|
|
|
|
|
private var currentDefaultValue = 0.0 |
|
|
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
@ -29,6 +30,10 @@ class BottomSheetSumFragment : BottomSheetFragment() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun getValue(): Any? { |
|
|
|
override fun getValue(): Any? { |
|
|
|
|
|
|
|
val editText2Value = editText2.text ?: "" |
|
|
|
|
|
|
|
if (editText2Value.isEmpty()) { |
|
|
|
|
|
|
|
return currentDefaultValue |
|
|
|
|
|
|
|
} |
|
|
|
return value |
|
|
|
return value |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -52,7 +57,7 @@ class BottomSheetSumFragment : BottomSheetFragment() { |
|
|
|
if (data.size == 5) { |
|
|
|
if (data.size == 5) { |
|
|
|
|
|
|
|
|
|
|
|
// Default value for the sum |
|
|
|
// Default value for the sum |
|
|
|
val currentDefaultValue = try { |
|
|
|
currentDefaultValue = try { |
|
|
|
data[2].defaultValue as Double |
|
|
|
data[2].defaultValue as Double |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
0.0 |
|
|
|
0.0 |
|
|
|
@ -67,7 +72,7 @@ class BottomSheetSumFragment : BottomSheetFragment() { |
|
|
|
0.0 |
|
|
|
0.0 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
button1.text = defaultValue1.toCurrency() |
|
|
|
button1.text = "+ ${defaultValue1.toCurrency()}" |
|
|
|
button1.visibility = if (defaultValue1 > 0) View.VISIBLE else View.GONE |
|
|
|
button1.visibility = if (defaultValue1 > 0) View.VISIBLE else View.GONE |
|
|
|
button1.setOnClickListener { |
|
|
|
button1.setOnClickListener { |
|
|
|
this.delegate.onRowValueChanged(currentDefaultValue + defaultValue1, row) |
|
|
|
this.delegate.onRowValueChanged(currentDefaultValue + defaultValue1, row) |
|
|
|
@ -81,7 +86,7 @@ class BottomSheetSumFragment : BottomSheetFragment() { |
|
|
|
0.0 |
|
|
|
0.0 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
button2.text = defaultValue2.toCurrency() |
|
|
|
button2.text = "+ ${defaultValue2.toCurrency()}" |
|
|
|
button2.visibility = if (defaultValue2 > 0) View.VISIBLE else View.GONE |
|
|
|
button2.visibility = if (defaultValue2 > 0) View.VISIBLE else View.GONE |
|
|
|
button2.setOnClickListener { |
|
|
|
button2.setOnClickListener { |
|
|
|
this.delegate.onRowValueChanged(currentDefaultValue + defaultValue2, row) |
|
|
|
this.delegate.onRowValueChanged(currentDefaultValue + defaultValue2, row) |
|
|
|
@ -105,7 +110,11 @@ class BottomSheetSumFragment : BottomSheetFragment() { |
|
|
|
data[4].hint?.let { editText2.hint = getString(it) } |
|
|
|
data[4].hint?.let { editText2.hint = getString(it) } |
|
|
|
editText2.inputType = data[4].inputType ?: InputType.TYPE_CLASS_TEXT |
|
|
|
editText2.inputType = data[4].inputType ?: InputType.TYPE_CLASS_TEXT |
|
|
|
editText2.addTextChangedListener { |
|
|
|
editText2.addTextChangedListener { |
|
|
|
value = it.toString().toDouble() |
|
|
|
value = try { |
|
|
|
|
|
|
|
it.toString().toDouble() |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
0.0 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
editText2.setOnEditorActionListener { v, actionId, event -> |
|
|
|
editText2.setOnEditorActionListener { v, actionId, event -> |
|
|
|
|