Shows hero in read mode

hh
Laurent 5 years ago
parent fc69ebce13
commit 7156f00d82
  1. 6
      app/src/main/java/net/pokeranalytics/android/ui/modules/feed/FeedFragment.kt
  2. 4
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  3. 9
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt
  4. 11
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/PlayerSetupRow.kt
  5. 35
      app/src/main/java/net/pokeranalytics/android/ui/view/PlayerImageView.kt
  6. 2
      app/src/main/res/layout/row_hhsettings_player_setup_read.xml

@ -466,9 +466,9 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate {
*/
private fun createNewHandHistory() {
val intent = Intent(requireContext(), TestActivity::class.java)
startActivity(intent)
return
// val intent = Intent(requireContext(), TestActivity::class.java)
// startActivity(intent)
// return
AppGuard.endOfUse?.let { endDate ->

@ -301,10 +301,12 @@ class HandHistoryAdapter(
val size = PlayerImageView.Size.SMALL
val players = dataSource.contentForRow(row, itemView.context, Player::class)
val isHero = dataSource.boolForRow(row)
if (players.isNotEmpty()) {
playerImageView.setPlayer(players.first(), size)
playerImageView.setPlayer(players.first(), size, isHero)
} else {
playerImageView.clear(size)
playerImageView.setStrokeColor(isHero)
}
}

@ -832,6 +832,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
override fun boolForRow(row: RowRepresentable): Boolean {
return when (row) {
HandRowType.BIG_BLIND_ANTE -> this.handHistory.bigBlindAnte
is PositionalRow -> row.positionIndex == this.handHistory.heroIndex
else -> throw PAIllegalStateException("undefined boolForRow for $row")
}
}
@ -897,7 +898,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
val hh = this.handHistory
return hh.playerSetups.sortedBy { it.position }.map {
val position = this.positionForIndex(it.position)
createPlayerSetupRow(position, it.position, hero = false, readMode = true)
createPlayerSetupRow(position, it.position, readMode = true)
}
}
@ -914,8 +915,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
val existingSetups = hh.playerSetups.sortedBy { it.position }.map {
val position = this.positionForIndex(it.position)
val hero = (it.position == hh.heroIndex)
createPlayerSetupRow(position, it.position, hero)
createPlayerSetupRow(position, it.position)
}
arrangedSetups.addAll(existingSetups)
@ -929,10 +929,9 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
private fun createPlayerSetupRow(
position: Position,
positionIndex: Int,
hero: Boolean,
readMode: Boolean = false
): PlayerSetupRow {
return PlayerSetupRow(hero, readMode, position, positionIndex, this.handHistory, this.playerHandMaxCards)
return PlayerSetupRow(readMode, position, positionIndex, this.handHistory, this.playerHandMaxCards)
}
/***

@ -1,14 +1,11 @@
package net.pokeranalytics.android.ui.modules.handhistory.model
import android.content.Context
import net.pokeranalytics.android.R
import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.model.handhistory.Position
import net.pokeranalytics.android.model.realm.handhistory.HandHistory
import net.pokeranalytics.android.ui.modules.handhistory.HandRowType
class PlayerSetupRow(var hero: Boolean = false,
private var readMode: Boolean = false,
class PlayerSetupRow(private var readMode: Boolean = false,
position: Position,
positionIndex: Int,
handHistory: HandHistory,
@ -38,9 +35,9 @@ class PlayerSetupRow(var hero: Boolean = false,
return if (this.playerSetup != null) State.SETUP_ONLY else State.POSITIONS_ONLY
}
fun closePosition() {
this._state = null
}
// fun closePosition() {
// this._state = null
// }
// fun title(context: Context): String {
// return if (this.hero) {

@ -75,7 +75,7 @@ class PlayerImageView : FrameLayout {
/**
* Set the session data to the view
*/
fun setPlayer(player: Player, size: Size = Size.NORMAL) {
fun setPlayer(player: Player, size: Size = Size.NORMAL, isHero: Boolean = false) {
// Picture
if (player.hasPicture()) {
@ -96,12 +96,11 @@ class PlayerImageView : FrameLayout {
}
// Player color
val color = if (player.color != null) {
player.color as Int
} else if (player.hasPicture()) {
Color.TRANSPARENT
} else {
getColor(context, R.color.kaki)
val color = when {
player.color != null -> player.color as Int
player.hasPicture() -> Color.TRANSPARENT
isHero -> getColor(context, R.color.kaki_lighter)
else -> getColor(context, R.color.kaki)
}
// Stroke & initial
@ -119,6 +118,28 @@ class PlayerImageView : FrameLayout {
}
}
fun setStrokeColor(isHero: Boolean) {
val res: Int
val size: Size = Size.SMALL
val text: String
if (isHero) {
res = R.color.kaki_lighter
text = "H"
} else {
res = R.color.kaki
text = ""
}
val color = getColor(context, res)
val drawable = this.playerImageView.playerStroke.background as GradientDrawable?
drawable?.setStroke(size.getStrokeSize(), color)
this.playerImageView.playerInitial.text = text
this.playerImageView.playerInitial.setTextColor(color)
this.playerImageView.playerInitial.setTextSize(TypedValue.COMPLEX_UNIT_SP, size.getFontSize())
}
/**
* Set image click listener
*/

@ -33,7 +33,7 @@
android:id="@+id/stack_text_view"
style="@style/PokerAnalyticsTheme.TextView.RowTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="end|center_vertical"
android:maxLines="1"

Loading…
Cancel
Save