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

@ -159,11 +159,15 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
when (config.frameType) { when (config.frameType) {
ReplayerConfiguration.FrameType.STATE -> { ReplayerConfiguration.FrameType.STATE -> {
if (config.currentStep == Street.SUMMARY) { if (config.currentStep == Street.SUMMARY) {
val amount = 666.0
val color = colorForAmount(amount) val winnerPots = config.handHistory.winnerPots.firstOrNull { it.position == i }
val circle = config.animatedChipCircleFromPot(i) winnerPots?.let { pot ->
drawChipCircle(circle, color, canvas, context) val color = colorForAmount(pot.amount)
drawChipText(amount, config.chipText(i), canvas, context) val circle = config.animatedChipCircleFromPot(i)
drawChipCircle(circle, color, canvas, context)
drawChipText(pot.amount, config.chipText(i), canvas, context)
}
} }
} }
ReplayerConfiguration.FrameType.GATHER_ANIMATION -> { ReplayerConfiguration.FrameType.GATHER_ANIMATION -> {
@ -174,49 +178,19 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
} }
} }
ReplayerConfiguration.FrameType.DISTRIBUTION_ANIMATION -> { ReplayerConfiguration.FrameType.DISTRIBUTION_ANIMATION -> {
val amount = 666.0
val winnerPots = config.handHistory.winnerPots.firstOrNull { it.position == i }
val color = colorForAmount(amount) winnerPots?.let { pot ->
val circle = config.animatedChipCircleFromPot(i) val color = colorForAmount(pot.amount)
drawChipCircle(circle, color, canvas, context) 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 -> { is ComputedAction -> {
drawChipForAction(i, config, canvas, context) 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) { private fun drawPlayerCircle(i: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) {
val playerSetup = config.handHistory.playerSetupForPosition(i) 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) { 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) val cards = config.handHistory.cardsForStreet(street)
config.boardCardRects.take(street.totalBoardCards).forEachIndexed { index, rectF -> config.boardCardRects.take(street.totalBoardCards).forEachIndexed { index, rectF ->
drawCard(cards[index], rectF, config, canvas, context) 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 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 true -> R.color.green
false -> R.color.red false -> R.color.red
else -> R.color.kaki_light else -> R.color.kaki_light

Loading…
Cancel
Save