|
|
|
|
@ -4,29 +4,41 @@ import android.os.Bundle |
|
|
|
|
import android.text.InputType |
|
|
|
|
import android.view.LayoutInflater |
|
|
|
|
import android.view.View |
|
|
|
|
import android.view.ViewGroup |
|
|
|
|
import android.view.inputmethod.EditorInfo |
|
|
|
|
import androidx.core.widget.addTextChangedListener |
|
|
|
|
import kotlinx.android.synthetic.main.bottom_sheet_double_edit_text.* |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.* |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.databinding.BottomSheetDoubleEditTextBinding |
|
|
|
|
import net.pokeranalytics.android.exceptions.RowRepresentableEditDescriptorException |
|
|
|
|
import net.pokeranalytics.android.util.extensions.round |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BottomSheetDoubleEditTextFragment : BottomSheetFragment() { |
|
|
|
|
|
|
|
|
|
private var _binding: BottomSheetDoubleEditTextBinding? = null |
|
|
|
|
private val binding get() = _binding!! |
|
|
|
|
|
|
|
|
|
override fun getChildView(inflater: LayoutInflater, container: ViewGroup): View? { |
|
|
|
|
_binding = BottomSheetDoubleEditTextBinding.inflate(inflater, container, true) |
|
|
|
|
return binding.root |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onDestroyView() { |
|
|
|
|
super.onDestroyView() |
|
|
|
|
_binding = null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
|
initData() |
|
|
|
|
initData() |
|
|
|
|
initUI() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onStart() { |
|
|
|
|
super.onStart() |
|
|
|
|
if (this.model.isEditingBlinds) { |
|
|
|
|
editText2.requestFocus() |
|
|
|
|
binding.editText2.requestFocus() |
|
|
|
|
} else { |
|
|
|
|
editText.requestFocus() |
|
|
|
|
binding.editText.requestFocus() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -47,56 +59,47 @@ class BottomSheetDoubleEditTextFragment : BottomSheetFragment() { |
|
|
|
|
throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor inconsistency") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// values.add(0, "") |
|
|
|
|
// values.add(1, "") |
|
|
|
|
|
|
|
|
|
LayoutInflater.from(requireContext()) |
|
|
|
|
.inflate(R.layout.bottom_sheet_double_edit_text, view?.bottomSheetContainer, true) |
|
|
|
|
|
|
|
|
|
// values[0] = (data[0].defaultValue ?: "").toString() |
|
|
|
|
// values[1] = (data[1].defaultValue ?: "").toString() |
|
|
|
|
|
|
|
|
|
data[0].hintResId?.let { editText.hint = getString(it) } |
|
|
|
|
editText.inputType = data[0].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES |
|
|
|
|
data[1].hintResId?.let { editText2.hint = getString(it) } |
|
|
|
|
editText2.inputType = data[1].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES |
|
|
|
|
data[0].hintResId?.let { binding.editText.hint = getString(it) } |
|
|
|
|
binding.editText.inputType = data[0].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES |
|
|
|
|
data[1].hintResId?.let { binding.editText2.hint = getString(it) } |
|
|
|
|
binding.editText2.inputType = data[1].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES |
|
|
|
|
|
|
|
|
|
if (this.model.valueAsHint) { |
|
|
|
|
|
|
|
|
|
this.model.stringValue?.let { |
|
|
|
|
if (it.isNotBlank()) { |
|
|
|
|
editText.hint = it |
|
|
|
|
binding.editText.hint = it |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.model.secondStringValue?.let { |
|
|
|
|
if (it.isNotBlank()) { |
|
|
|
|
editText2.hint = it |
|
|
|
|
binding.editText2.hint = it |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// if (this.viewModel.stringValue?.isNotBlank()) { editText.hint = values[0] } |
|
|
|
|
// if (values[1].isNotBlank()) { editText2.hint = values[1] } |
|
|
|
|
} else { |
|
|
|
|
editText.setText(this.model.stringValue) |
|
|
|
|
editText2.setText(this.model.secondStringValue) |
|
|
|
|
binding.editText.setText(this.model.stringValue) |
|
|
|
|
binding.editText2.setText(this.model.secondStringValue) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
editText.addTextChangedListener { |
|
|
|
|
binding.editText.addTextChangedListener { |
|
|
|
|
this.model.stringValue = it?.toString() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
editText2.addTextChangedListener { |
|
|
|
|
binding.editText2.addTextChangedListener { |
|
|
|
|
this.model.secondStringValue = it?.toString() |
|
|
|
|
if (this.model.isEditingBlinds) { |
|
|
|
|
try { |
|
|
|
|
val bigBlind = this.model.secondStringValue?.toDouble() ?: 0.0 |
|
|
|
|
editText.setText((bigBlind / 2.0).round()) |
|
|
|
|
binding.editText.setText((bigBlind / 2.0).round()) |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
editText.setText("") |
|
|
|
|
binding.editText.setText("") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
editText2.setOnEditorActionListener { _, actionId, _ -> |
|
|
|
|
binding.editText2.setOnEditorActionListener { _, actionId, _ -> |
|
|
|
|
if (actionId == EditorInfo.IME_ACTION_DONE) { |
|
|
|
|
this.onRowValueChanged() |
|
|
|
|
// this.delegate.onRowValueChanged(values, row) |
|
|
|
|
|