diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt index 59c14659..6d7e7f7c 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.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(hhId)?.defineWinnerPositions() } realm.close() } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/TableDrawer.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/TableDrawer.kt index 1d50b5c0..15512494 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/TableDrawer.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/TableDrawer.kt @@ -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 circle = config.animatedChipCircleFromPot(i) - drawChipCircle(circle, color, canvas, context) - drawChipText(amount, config.chipText(i), canvas, context) + + 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(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 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) -// } + + 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) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/RowHandHistoryViewHolder.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/RowHandHistoryViewHolder.kt index 56ead43b..724d9192 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/RowHandHistoryViewHolder.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/RowHandHistoryViewHolder.kt @@ -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