Better error for crash

kmm_hh
Laurent 5 years ago
parent 28f823b121
commit b7d398b79b
  1. 14
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/EditorViewModel.kt

@ -113,9 +113,11 @@ class EditorViewModel : ViewModel(), RowRepresentableDataSource, CardCentralizer
*/ */
val currentKeyboard: HHKeyboard? val currentKeyboard: HHKeyboard?
get() { get() {
this.selectionLiveData.value?.let { this.selectionLiveData.value?.let { selection ->
val row = this.rowRepresentables[it.index] as HandHistoryRow val row = this.rowRepresentables[selection.index]
return row.keyboardForTag(it.tag) (row as? HandHistoryRow)?.let { hhRow ->
return hhRow.keyboardForTag(selection.tag)
} ?: throw PAIllegalStateException("Row $row cannot be cast to HandHistoryRow")
} }
return null return null
} }
@ -695,11 +697,11 @@ class EditorViewModel : ViewModel(), RowRepresentableDataSource, CardCentralizer
// Row Representable Datasource // Row Representable Datasource
override fun adapterRows(): List<RowRepresentable>? { override fun adapterRows(): List<RowRepresentable> {
return this.rowRepresentables return this.rowRepresentables
} }
override fun rowRepresentableForPosition(position: Int): RowRepresentable? { override fun rowRepresentableForPosition(position: Int): RowRepresentable {
return this.rowRepresentables[position] return this.rowRepresentables[position]
} }
@ -859,7 +861,7 @@ class EditorViewModel : ViewModel(), RowRepresentableDataSource, CardCentralizer
} }
} }
override fun backgroundColor(position: Int, row: RowRepresentable): Int? { override fun backgroundColor(position: Int, row: RowRepresentable): Int {
return if (this.isEdited) { return if (this.isEdited) {
if (position < this.settingsRowCount) R.color.green_header else R.color.transparent if (position < this.settingsRowCount) R.color.green_header else R.color.transparent
} else { } else {

Loading…
Cancel
Save