|
|
|
@ -39,6 +39,7 @@ import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.holder.RowViewHolder |
|
|
|
import net.pokeranalytics.android.ui.view.holder.RowViewHolder |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.ViewIdentifier |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.ViewIdentifier |
|
|
|
import net.pokeranalytics.android.util.extensions.formatted |
|
|
|
import net.pokeranalytics.android.util.extensions.formatted |
|
|
|
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable { |
|
|
|
enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable { |
|
|
|
@ -314,29 +315,31 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
|
|
val focused = dataSource.isSelected(this.currentPosition, row, layout.tag as Int) |
|
|
|
val focused = dataSource.isSelected(this.currentPosition, row, layout.tag as Int) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// background |
|
|
|
val drawableId = when { |
|
|
|
val drawableId = when { |
|
|
|
focused -> R.drawable.rounded_highlighted_board_background |
|
|
|
focused -> R.drawable.rounded_highlighted_board_background |
|
|
|
isBoard || isEdited -> R.drawable.rounded_board_background |
|
|
|
isBoard || isEdited -> R.drawable.rounded_board_background |
|
|
|
else -> R.drawable.transparent |
|
|
|
else -> R.drawable.transparent |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
layout.background = itemView.resources.getDrawable(drawableId, null) |
|
|
|
layout.background = itemView.resources.getDrawable(drawableId, null) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Cards |
|
|
|
dataSource.contentForRow(row, itemView.context, Card::class).forEach { card -> |
|
|
|
dataSource.contentForRow(row, itemView.context, Card::class).forEach { card -> |
|
|
|
val cardView = card.view(itemView.context, inflater, layout) |
|
|
|
val cardView = card.view(itemView.context, inflater, layout) |
|
|
|
layout.addView(cardView) |
|
|
|
layout.addView(cardView) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (layout.isEmpty()) { |
|
|
|
if (layout.isEmpty() && isEdited) { // adds layout hint |
|
|
|
val hintView = TextView(itemView.context) |
|
|
|
val hintView = TextView(itemView.context) |
|
|
|
val hintResId = if (isBoard) R.string.board else R.string.hand |
|
|
|
val hintResId = if (isBoard) R.string.board else R.string.hand |
|
|
|
hintView.text = itemView.context.getString(hintResId) |
|
|
|
hintView.text = itemView.context.getString(hintResId).capitalize() |
|
|
|
layout.addView(hintView) |
|
|
|
layout.addView(hintView) |
|
|
|
layout.gravity = Gravity.CENTER |
|
|
|
layout.gravity = Gravity.CENTER |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
layout.gravity = if (isBoard || !isEdited) Gravity.START or Gravity.CENTER_VERTICAL else Gravity.CENTER |
|
|
|
layout.gravity = if (isBoard || !isEdited) Gravity.START or Gravity.CENTER_VERTICAL else Gravity.CENTER |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Listener |
|
|
|
layout.setOnClickListener { |
|
|
|
layout.setOnClickListener { |
|
|
|
delegate?.onRowSelected(this.currentPosition, row, layout.tag as Int) |
|
|
|
delegate?.onRowSelected(this.currentPosition, row, layout.tag as Int) |
|
|
|
} |
|
|
|
} |
|
|
|
|