Refactoring

bs
Laurent 5 years ago
parent 7383e4af01
commit 62c042cd0e
  1. 10
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerAnimator.kt
  2. 14
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/TableDrawer.kt

@ -441,7 +441,15 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) {
return this.handHistory.playerSetupForPosition(positionIndex)?.stack
}
fun lastChipCommittingActionOfPlayer(positionIndex: Int): ComputedAction? {
fun lastCommittedAmount(i: Int): Double? {
var committingAction = lastChipCommittingActionOfPlayer(i)
if (committingAction?.action?.type?.isCall == true) {
committingAction = committingAction.getStreetLastSignificantAction()
}
return committingAction?.action?.amount
}
private fun lastChipCommittingActionOfPlayer(positionIndex: Int): ComputedAction? {
this.lastActionAtStep?.action?.index?.let { index ->
return this.actionList.lastChipCommittingActionOfPlayer(positionIndex, index)
}

@ -14,7 +14,7 @@ import net.pokeranalytics.android.util.extensions.formatted
class TableDrawer {
lateinit var animator: ReplayerAnimator
private lateinit var animator: ReplayerAnimator
private val backgroundColor = R.color.green_darker
private val backgroundPaint = Paint()
@ -151,7 +151,7 @@ class TableDrawer {
}
}
FrameType.GATHER_ANIMATION -> {
lastCommittedAmount(i)?.let { amount ->
animator.lastCommittedAmount(i)?.let { amount ->
val color = colorForAmount(amount)
val circle = animator.animatedChipCircleToPot(i)
drawChipCircle(circle, color, canvas, context)
@ -176,19 +176,11 @@ class TableDrawer {
}
private fun drawChipForAction(i: Int, canvas: Canvas, context: Context) {
lastCommittedAmount(i)?.let { amount ->
animator.lastCommittedAmount(i)?.let { amount ->
drawChip(amount, i, canvas, context)
}
}
private fun lastCommittedAmount(i: Int): Double? {
var committingAction = animator.lastChipCommittingActionOfPlayer(i)
if (committingAction?.action?.type?.isCall == true) {
committingAction = committingAction.getStreetLastSignificantAction()
}
return committingAction?.action?.amount
}
/***
* WARNING: Avoid instancing objects here, as it's called from onDraw method
*/

Loading…
Cancel
Save