|
|
|
|
@ -5,6 +5,7 @@ import net.pokeranalytics.android.model.handhistory.Position |
|
|
|
|
import net.pokeranalytics.android.model.handhistory.Street |
|
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.Action |
|
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.HandHistory |
|
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.toReadRow |
|
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.HandRowType |
|
|
|
|
import kotlin.math.max |
|
|
|
|
import kotlin.math.min |
|
|
|
|
@ -13,13 +14,13 @@ import kotlin.math.min |
|
|
|
|
* An extension to transform a list of ComputedAction into |
|
|
|
|
* a more compact and read-friendly list of ActionReadRow |
|
|
|
|
*/ |
|
|
|
|
fun List<ComputedAction>.compact(): List<ActionReadRow> { |
|
|
|
|
fun List<ComputedAction>.compact(positions: LinkedHashSet<Position>, heroIndex: Int?): List<ActionReadRow> { |
|
|
|
|
val rows = mutableListOf<ActionReadRow>() |
|
|
|
|
this.forEach { |
|
|
|
|
if (it.action.type == Action.Type.FOLD && rows.lastOrNull()?.action == Action.Type.FOLD) { |
|
|
|
|
rows.lastOrNull()?.positions?.add(it.position) |
|
|
|
|
} else { |
|
|
|
|
rows.add(it.toReadRow()) |
|
|
|
|
rows.add(it.action.toReadRow(positions, heroIndex)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return rows |
|
|
|
|
@ -287,13 +288,6 @@ class ComputedAction(var manager: ActionManager, |
|
|
|
|
|
|
|
|
|
override val viewType: Int = HandRowType.ACTION.ordinal |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* The "read mode" representation of the action |
|
|
|
|
*/ |
|
|
|
|
fun toReadRow(): ActionReadRow { |
|
|
|
|
return ActionReadRow(mutableListOf(this.position), this.positionIndex, this.action.type, this.action.amount, this.isHero) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override val positionIndex: Int |
|
|
|
|
get() { return this.action.position } |
|
|
|
|
|
|
|
|
|
|