Bottom Sheet multiline fields are now initialized with null by default

feature/top10
Laurent 7 years ago
parent bf8e5c16e8
commit 8c3a689760
  1. 14
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetEditTextMultiLinesFragment.kt

@ -8,12 +8,11 @@ import androidx.core.widget.addTextChangedListener
import kotlinx.android.synthetic.main.bottom_sheet_edit_text_multi_lines.* import kotlinx.android.synthetic.main.bottom_sheet_edit_text_multi_lines.*
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.* import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.*
import net.pokeranalytics.android.exceptions.RowRepresentableEditDescriptorException import net.pokeranalytics.android.exceptions.RowRepresentableEditDescriptorException
import java.lang.AssertionError
class BottomSheetEditTextMultiLinesFragment : BottomSheetFragment() { class BottomSheetEditTextMultiLinesFragment : BottomSheetFragment() {
private var value = "" private var value: String? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
@ -27,7 +26,10 @@ class BottomSheetEditTextMultiLinesFragment : BottomSheetFragment() {
} }
override fun getValue(): Any? { override fun getValue(): Any? {
return value.trim() this.value?.let {
return it.trim()
}
return null
} }
/** /**
@ -49,8 +51,10 @@ class BottomSheetEditTextMultiLinesFragment : BottomSheetFragment() {
data[0].hint?.let { editText1.hint = getString(it) } data[0].hint?.let { editText1.hint = getString(it) }
editText1.inputType = data[0].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES editText1.inputType = data[0].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
editText1.addTextChangedListener { value = it?.toString() ?: "" } editText1.addTextChangedListener { this.value = it?.toString() }
editText1.setText((data[0].defaultValue ?: "").toString()) data[0].defaultValue?.let {
editText1.setText(it.toString())
}
} }
} }
Loading…
Cancel
Save