Fix big blind edit text

feature/top10
Aurelien Hubert 7 years ago
parent 91ddd22ccb
commit dfa91af21a
  1. 26
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetDoubleEditTextFragment.kt

@ -26,8 +26,13 @@ class BottomSheetDoubleEditTextFragment : BottomSheetFragment() {
override fun onStart() {
super.onStart()
if (isEditingBlinds) {
editText2.requestFocus()
} else {
editText1.requestFocus()
}
}
override fun getValue(): Any? {
return values
@ -57,28 +62,29 @@ class BottomSheetDoubleEditTextFragment : BottomSheetFragment() {
if (data.size == 2) {
editText1.setText((data[0].defaultValue ?: "").toString())
editText2.setText((data[1].defaultValue ?: "").toString())
data[0].hint?.let { editText1.hint = getString(it) }
editText1.inputType = data[0].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
editText1.addTextChangedListener {
values[0] = it?.toString() ?: ""
if (isEditingBlinds) {
try {
val smallBlind = values[0].toDouble()
editText2.setText((smallBlind * 2).round())
} catch (e: Exception) {
editText2.setText("")
}
}
}
data[1].hint?.let { editText2.hint = getString(it) }
editText2.inputType = data[1].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
editText2.addTextChangedListener {
values[1] = it?.toString() ?: ""
if (isEditingBlinds) {
try {
val bigBlind = values[1].toDouble()
editText1.setText((bigBlind / 2.0).round())
} catch (e: Exception) {
editText1.setText("")
}
}
}
editText1.setText((data[0].defaultValue ?: "").toString())
editText2.setText((data[1].defaultValue ?: "").toString())
editText2.setOnEditorActionListener { v, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {

Loading…
Cancel
Save