Fixes won pot save and replayer end animation

hh
Laurent 5 years ago
parent 37fd11d162
commit 40d60ff559
  1. 4
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt
  2. 56
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/TableDrawer.kt
  3. 3
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/RowHandHistoryViewHolder.kt

@ -26,6 +26,7 @@ import net.pokeranalytics.android.ui.modules.handhistory.views.CardCentralizer
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable
import net.pokeranalytics.android.util.extensions.findById
import net.pokeranalytics.android.util.extensions.formatted
import timber.log.Timber
import kotlin.coroutines.CoroutineContext
@ -627,11 +628,12 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
private fun defineWinnerPositions() {
val hhId = this.handHistory.id
GlobalScope.launch(coroutineContext) {
val c = GlobalScope.async {
val realm = Realm.getDefaultInstance()
realm.executeTransaction {
handHistory.defineWinnerPositions()
realm.findById<HandHistory>(hhId)?.defineWinnerPositions()
}
realm.close()
}

@ -159,11 +159,15 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
when (config.frameType) {
ReplayerConfiguration.FrameType.STATE -> {
if (config.currentStep == Street.SUMMARY) {
val amount = 666.0
val color = colorForAmount(amount)
val winnerPots = config.handHistory.winnerPots.firstOrNull { it.position == i }
winnerPots?.let { pot ->
val color = colorForAmount(pot.amount)
val circle = config.animatedChipCircleFromPot(i)
drawChipCircle(circle, color, canvas, context)
drawChipText(amount, config.chipText(i), canvas, context)
drawChipText(pot.amount, config.chipText(i), canvas, context)
}
}
}
ReplayerConfiguration.FrameType.GATHER_ANIMATION -> {
@ -174,49 +178,19 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
}
}
ReplayerConfiguration.FrameType.DISTRIBUTION_ANIMATION -> {
val amount = 666.0
val color = colorForAmount(amount)
val winnerPots = config.handHistory.winnerPots.firstOrNull { it.position == i }
winnerPots?.let { pot ->
val color = colorForAmount(pot.amount)
val circle = config.animatedChipCircleFromPot(i)
drawChipCircle(circle, color, canvas, context)
// Timber.d("won pots = ${config.handHistory.winnerPots}")
// val winnerPots = config.handHistory.winnerPots.firstOrNull { it.position == i }
// winnerPots?.let { pot ->
// val color = colorForAmount(pot.amount)
// val circle = config.animatedChipCircleFromPot(i)
// drawChipCircle(circle, color, canvas, context)
// }
}
}
}
}
is ComputedAction -> {
drawChipForAction(i, config, canvas, context)
}
// is HandStep.GatherChips -> {
// lastCommittedAmount(i, config)?.let { amount ->
// val color = colorForAmount(amount)
// val circle = config.animatedChipCircleToPot(i)
// drawChipCircle(circle, color, canvas, context)
// }
// }
// is HandStep.DistributeChips -> {
// config.handHistory.winnerPots.firstOrNull { it.position == i }?.let { pot ->
// val color = colorForAmount(pot.amount)
// val circle = config.animatedChipCircleFromPot(i)
// drawChipCircle(circle, color, canvas, context)
// }
// }
// is Street -> { // animate chips
// if (!config.isLastFrame) {
// lastCommittedAmount(i, config)?.let { amount ->
// val color = colorForAmount(amount)
// val circle = config.animatedChipCircle(i)
// drawChipCircle(circle, color, canvas, context)
// }
// }
// }
}
}
@ -346,11 +320,6 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
}
// private fun drawPlayerPositionAndStack(action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) {
// drawPlayerRectangle(action.positionIndex,false, config, canvas, context)
// drawPositionAndStack(action.positionIndex, action.stackAfterActing, config, canvas, context)
// }
private fun drawPlayerCircle(i: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) {
val playerSetup = config.handHistory.playerSetupForPosition(i)
@ -451,9 +420,6 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
private fun drawBoardCards(street: Street, config: ReplayerConfiguration, canvas: Canvas, context: Context) {
// when the step is the street, we wait for the last frame to display the board
// if ((config.currentStep == street && config.isLastFrame) || config.currentStep != street) {
// }
val cards = config.handHistory.cardsForStreet(street)
config.boardCardRects.take(street.totalBoardCards).forEachIndexed { index, rectF ->
drawCard(cards[index], rectF, config, canvas, context)

@ -31,7 +31,8 @@ class RowHandHistoryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemVie
itemView.amount.text = handHistory.potSizeForStreet(Street.SUMMARY).formatted
val colorId = when(handHistory.heroWins) {
val heroWins = handHistory.heroWins
val colorId = when(heroWins) {
true -> R.color.green
false -> R.color.red
else -> R.color.kaki_light

Loading…
Cancel
Save