Bottom Sheet text fields are now initialized with null by default

feature/top10
Laurent 7 years ago
parent 0b8062e4c5
commit bf8e5c16e8
  1. 6
      app/src/main/java/net/pokeranalytics/android/model/realm/Result.kt
  2. 15
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  3. 13
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetEditTextFragment.kt

@ -26,6 +26,9 @@ open class Result : RealmObject() {
set(value) {
field = value
this.computeNet()
if (value != null) {
this.session?.end()
}
}
/**
@ -35,6 +38,9 @@ open class Result : RealmObject() {
set(value) {
field = value
this.computeNet()
if (value != null) {
this.session?.end()
}
}
/**

@ -462,7 +462,7 @@ open class Session : RealmObject(), Identifiable, Manageable, StaticRowRepresent
/**
* Utility method to cleanly end a session
*/
private fun end() {
fun end() {
this.pauseDate = null
if (this.endDate == null) {
this.endDate = Date()
@ -702,9 +702,12 @@ open class Session : RealmObject(), Identifiable, Manageable, StaticRowRepresent
"ratedBuyin" to ratedBuyin
))
SessionRow.BREAK_TIME -> row.editingDescriptors(mapOf())
SessionRow.CASHED_OUT, SessionRow.PRIZE, SessionRow.NET_RESULT -> row.editingDescriptors(mapOf(
SessionRow.CASHED_OUT, SessionRow.PRIZE -> row.editingDescriptors(mapOf(
"defaultValue" to result?.cashout?.round()
))
SessionRow.NET_RESULT -> row.editingDescriptors(mapOf(
"defaultValue" to result?.netResult?.round()
))
SessionRow.COMMENT -> row.editingDescriptors(mapOf(
"defaultValue" to this.comment))
SessionRow.INITIAL_BUY_IN -> row.editingDescriptors(mapOf(
@ -758,18 +761,22 @@ open class Session : RealmObject(), Identifiable, Manageable, StaticRowRepresent
this.result = localResult
this.updateRowRepresentation()
}
SessionRow.CASHED_OUT, SessionRow.PRIZE, SessionRow.NET_RESULT -> {
SessionRow.CASHED_OUT, SessionRow.PRIZE -> {
val localResult = if (this.result != null) this.result as Result else realm.createObject(Result::class.java)
if (value == null) {
localResult.cashout = null
} else {
localResult.cashout = (value as String).toDouble()
this.end()
}
this.result = localResult
}
SessionRow.NET_RESULT -> {
this.result?.let { result ->
result.netResult = (value as String).toDouble()
}
}
SessionRow.COMMENT -> comment = value as String? ?: ""
SessionRow.END_DATE -> if (value is Date?) {

@ -14,7 +14,7 @@ import net.pokeranalytics.android.exceptions.RowRepresentableEditDescriptorExcep
class BottomSheetEditTextFragment : BottomSheetFragment() {
private var value = ""
private var value: String? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -28,7 +28,10 @@ class BottomSheetEditTextFragment : BottomSheetFragment() {
}
override fun getValue(): Any? {
return value.trim()
this.value?.let {
return it.trim()
}
return null
}
/**
@ -50,8 +53,10 @@ class BottomSheetEditTextFragment : BottomSheetFragment() {
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 { value = it?.toString() ?: "" }
editText1.setText((data[0].defaultValue ?: "").toString())
editText1.addTextChangedListener { this.value = it?.toString() }
data[0].defaultValue?.let {
editText1.setText(it.toString())
}
editText1.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {

Loading…
Cancel
Save