Fixes build

hh
Laurent 6 years ago
parent f624546598
commit b5f238d165
  1. 15
      app/src/main/java/net/pokeranalytics/android/model/handhistory/ComputedAction.kt
  2. 9
      app/src/main/java/net/pokeranalytics/android/model/handhistory/HHBuilder.kt
  3. 8
      app/src/main/java/net/pokeranalytics/android/ui/view/handhistory/StreetCardHeader.kt
  4. 4
      app/src/main/java/net/pokeranalytics/android/ui/viewmodel/HandHistoryViewModel.kt

@ -3,9 +3,10 @@ package net.pokeranalytics.android.model.handhistory
import net.pokeranalytics.android.model.realm.handhistory.Action import net.pokeranalytics.android.model.realm.handhistory.Action
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType import net.pokeranalytics.android.ui.view.RowViewType
import net.pokeranalytics.android.ui.view.handhistory.HandHistoryKeyboard
interface HandHistoryRow : RowRepresentable { interface HandHistoryRow : RowRepresentable {
fun isValid() : Boolean fun keyboardForCompletion() : HandHistoryKeyboard?
} }
class ComputedAction(var action: Action, class ComputedAction(var action: Action,
@ -38,15 +39,15 @@ class ComputedAction(var action: Action,
override val viewType: Int = RowViewType.ROW_HAND_ACTION.ordinal override val viewType: Int = RowViewType.ROW_HAND_ACTION.ordinal
override fun isValid() : Boolean { override fun keyboardForCompletion() : HandHistoryKeyboard? {
return action.type?.let { type -> this.action.type?.let { type ->
if (this.requireAmount) { if (this.requireAmount && this.action.amount == null) {
return this.action.amount != null return HandHistoryKeyboard.ACTION
} else { } else {
return true return null
} }
} ?: run { } ?: run {
false return HandHistoryKeyboard.ACTION
} }
} }

@ -6,6 +6,7 @@ import net.pokeranalytics.android.model.realm.handhistory.Action
import net.pokeranalytics.android.model.realm.handhistory.HandHistory import net.pokeranalytics.android.model.realm.handhistory.HandHistory
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType import net.pokeranalytics.android.ui.view.RowViewType
import net.pokeranalytics.android.ui.view.handhistory.HandHistoryKeyboard
import net.pokeranalytics.android.ui.view.handhistory.StreetCardHeader import net.pokeranalytics.android.ui.view.handhistory.StreetCardHeader
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable
import java.util.* import java.util.*
@ -304,12 +305,12 @@ class HHBuilder {
/*** /***
* Finds the index of the first incomplete action, if existing * Finds the index of the first incomplete action, if existing
*/ */
fun findIndexForEdition(): RowRepresentable? { fun findIndexForEdition(): Pair<Int, HandHistoryKeyboard>? {
this.currentRowRepresentables.forEach { rowRepresentable -> this.currentRowRepresentables.forEachIndexed { index, rowRepresentable ->
if (rowRepresentable is HandHistoryRow) { if (rowRepresentable is HandHistoryRow) {
if (!rowRepresentable.isValid()) { rowRepresentable.keyboardForCompletion()?.let { keyboard ->
return rowRepresentable return Pair(index, keyboard)
} }
} }
} }

@ -9,8 +9,12 @@ class StreetCardHeader(var street: Street, var cards: List<Card>, var potSize: D
override val viewType: Int = RowViewType.ROW_HAND_STREET.ordinal override val viewType: Int = RowViewType.ROW_HAND_STREET.ordinal
override fun isValid(): Boolean { override fun keyboardForCompletion(): HandHistoryKeyboard? {
return cards.size == street.totalBoardCards return if (cards.size != street.totalBoardCards) {
HandHistoryKeyboard.CARD
} else {
null
}
} }
} }

@ -3,10 +3,12 @@ package net.pokeranalytics.android.ui.viewmodel
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import net.pokeranalytics.android.exceptions.PAIllegalStateException import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.model.handhistory.ComputedAction
import net.pokeranalytics.android.model.handhistory.HHBuilder import net.pokeranalytics.android.model.handhistory.HHBuilder
import net.pokeranalytics.android.model.realm.handhistory.Action import net.pokeranalytics.android.model.realm.handhistory.Action
import net.pokeranalytics.android.model.realm.handhistory.Card import net.pokeranalytics.android.model.realm.handhistory.Card
import net.pokeranalytics.android.ui.view.handhistory.HandHistoryKeyboard import net.pokeranalytics.android.ui.view.handhistory.HandHistoryKeyboard
import net.pokeranalytics.android.ui.view.handhistory.StreetCardHeader
class HandHistoryViewModel : ViewModel() { class HandHistoryViewModel : ViewModel() {
@ -52,8 +54,6 @@ class HandHistoryViewModel : ViewModel() {
return r?.second return r?.second
} ?: throw PAIllegalStateException("Builder not defined") } ?: throw PAIllegalStateException("Builder not defined")
} }
} }
Loading…
Cancel
Save