Added the ability to edit comment

hh
Laurent 6 years ago
parent f4acb0f805
commit 313b27e16a
  1. 3
      app/src/main/java/net/pokeranalytics/android/model/realm/Game.kt
  2. 3
      app/src/main/java/net/pokeranalytics/android/model/realm/Player.kt
  3. 3
      app/src/main/java/net/pokeranalytics/android/model/realm/TournamentFeature.kt
  4. 3
      app/src/main/java/net/pokeranalytics/android/model/realm/TournamentName.kt
  5. 3
      app/src/main/java/net/pokeranalytics/android/model/realm/TransactionType.kt
  6. 9
      app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt
  7. 4
      app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt
  8. 1
      app/src/main/java/net/pokeranalytics/android/ui/fragment/CurrenciesFragment.kt
  9. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/FilterDetailsFragment.kt
  10. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/FiltersFragment.kt
  11. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/SettingsFragment.kt
  12. 6
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetFragment.kt
  13. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetTableSizeGridFragment.kt
  14. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/data/BankrollDataFragment.kt
  15. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/data/CustomFieldDataFragment.kt
  16. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/data/LocationDataFragment.kt
  17. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/data/PlayerDataFragment.kt
  18. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/data/TransactionDataFragment.kt
  19. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/data/TransactionTypeDataFragment.kt
  20. 41
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  21. 40
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  22. 17
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt
  23. 29
      app/src/main/java/net/pokeranalytics/android/ui/view/holder/RowViewHolder.kt
  24. 2
      app/src/main/java/net/pokeranalytics/android/ui/viewmodel/BottomSheetViewModel.kt
  25. 33
      app/src/main/res/layout/row_hhsettings_comments.xml

@ -66,12 +66,13 @@ open class Game : RealmObject(), NameManageable, StaticRowRepresentableDataSourc
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
return when (row) { return when (row) {
SimpleRow.NAME -> if (this.name.isNotEmpty()) this.name else NULL_TEXT SimpleRow.NAME -> if (this.name.isNotEmpty()) this.name else NULL_TEXT
GameRow.SHORT_NAME -> this.shortName ?: NULL_TEXT GameRow.SHORT_NAME -> this.shortName ?: NULL_TEXT
else -> return super.stringForRow(row, 0) else -> return super.stringForRow(row, context, 0)
} }
} }

@ -77,11 +77,12 @@ open class Player : RealmObject(), NameManageable, Deletable, StaticRowRepresent
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
return when (row) { return when (row) {
PlayerRow.NAME -> if (this.name.isNotEmpty()) this.name else NULL_TEXT PlayerRow.NAME -> if (this.name.isNotEmpty()) this.name else NULL_TEXT
else -> return super.stringForRow(row, 0) else -> return super.stringForRow(row, context, 0)
} }
} }

@ -58,11 +58,12 @@ open class TournamentFeature : RealmObject(), NameManageable, StaticRowRepresent
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
return when (row) { return when (row) {
SimpleRow.NAME -> if (this.name.isNotEmpty()) this.name else NULL_TEXT SimpleRow.NAME -> if (this.name.isNotEmpty()) this.name else NULL_TEXT
else -> return super.stringForRow(row, 0) else -> return super.stringForRow(row, context, 0)
} }
} }

@ -55,11 +55,12 @@ open class TournamentName : RealmObject(), NameManageable, StaticRowRepresentabl
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
return when (row) { return when (row) {
SimpleRow.NAME -> if (this.name.isNotEmpty()) this.name else NULL_TEXT SimpleRow.NAME -> if (this.name.isNotEmpty()) this.name else NULL_TEXT
else -> return super.stringForRow(row, 0) else -> return super.stringForRow(row, context, 0)
} }
} }

@ -108,11 +108,12 @@ open class TransactionType : RealmObject(), NameManageable, StaticRowRepresentab
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
return when (row) { return when (row) {
SimpleRow.NAME -> this.name SimpleRow.NAME -> this.name
else -> return super.stringForRow(row, 0) else -> return super.stringForRow(row, context, 0)
} }
} }

@ -159,4 +159,13 @@ open class HandHistory : RealmObject(), RowRepresentable, Identifiable, Filterab
override val cards: RealmList<Card> override val cards: RealmList<Card>
get() { return this.board } get() { return this.board }
val anteSum: Double
get() {
return if (bigBlindAnte) {
this.bigBlind ?: 0.0
} else {
this.ante * this.numberOfPlayers
}
}
} }

@ -122,13 +122,13 @@ interface DisplayableDataSource {
* Returns a localized string for a specific row * Returns a localized string for a specific row
*/ */
fun stringForRow(row: RowRepresentable, context: Context): String { fun stringForRow(row: RowRepresentable, context: Context): String {
return stringForRow(row, 0) return stringForRow(row, context, 0)
} }
/** /**
* Returns a string for a specific row * Returns a string for a specific row
*/ */
fun stringForRow(row: RowRepresentable, tag: Int = 0): String { fun stringForRow(row: RowRepresentable, context: Context, tag: Int = 0): String {
return "" return ""
} }

@ -92,6 +92,7 @@ class CurrenciesFragment : BaseFragment(), StaticRowRepresentableDataSource, Row
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
return (row as CurrencyRow).currencyCodeAndSymbol return (row as CurrencyRow).currencyCodeAndSymbol

@ -99,7 +99,7 @@ open class FilterDetailsFragment : RealmFragment(), StaticRowRepresentableDataSo
override fun stringForRow(row: RowRepresentable, context: Context): String { override fun stringForRow(row: RowRepresentable, context: Context): String {
return when (row) { return when (row) {
is QueryCondition.ListOfValues<*> -> row.firstValue(context) is QueryCondition.ListOfValues<*> -> row.firstValue(context)
else -> super.stringForRow(row, 0) else -> super.stringForRow(row, context, 0)
} ?: NULL_TEXT } ?: NULL_TEXT
} }

@ -1,6 +1,7 @@
package net.pokeranalytics.android.ui.fragment package net.pokeranalytics.android.ui.fragment
import android.app.Activity.RESULT_OK import android.app.Activity.RESULT_OK
import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.* import android.view.*
@ -133,6 +134,7 @@ open class FiltersFragment : RealmFragment(), StaticRowRepresentableDataSource,
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
// Return the number of selected filters for this category // Return the number of selected filters for this category

@ -2,6 +2,7 @@ package net.pokeranalytics.android.ui.fragment
import android.app.Activity import android.app.Activity
import android.content.ActivityNotFoundException import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
@ -105,6 +106,7 @@ class SettingsFragment : BaseFragment(), RowRepresentableDelegate, StaticRowRepr
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
return when (row) { return when (row) {

@ -29,7 +29,7 @@ import java.util.*
class BottomSheetConfig(var row: RowRepresentable, class BottomSheetConfig(var row: RowRepresentable,
var delegate: RowRepresentableDelegate, var delegate: RowRepresentableDelegate,
var rowRepresentableEditDescriptors: ArrayList<RowRepresentableEditDescriptor>?, var rowRepresentableEditDescriptors: List<RowRepresentableEditDescriptor>?,
var isClearable: Boolean? = true, var isClearable: Boolean? = true,
var currentCurrency: Currency? = null, var currentCurrency: Currency? = null,
var isDeletable: Boolean? = false, var isDeletable: Boolean? = false,
@ -56,7 +56,7 @@ open class BottomSheetFragment : BottomSheetDialogFragment() {
fragmentManager: FragmentManager?, fragmentManager: FragmentManager?,
row: RowRepresentable, row: RowRepresentable,
delegate: RowRepresentableDelegate, delegate: RowRepresentableDelegate,
rowRepresentableEditDescriptors: ArrayList<RowRepresentableEditDescriptor>?, rowRepresentableEditDescriptors: List<RowRepresentableEditDescriptor>?,
isClearable: Boolean? = true, isClearable: Boolean? = true,
currentCurrency: Currency? = null, currentCurrency: Currency? = null,
isDeletable: Boolean? = false, isDeletable: Boolean? = false,
@ -204,7 +204,7 @@ open class BottomSheetFragment : BottomSheetDialogFragment() {
/** /**
* Return the data list * Return the data list
*/ */
fun getDescriptors(): ArrayList<RowRepresentableEditDescriptor>? { fun getDescriptors(): List<RowRepresentableEditDescriptor>? {
return this.viewModel.rowRepresentableEditDescriptors return this.viewModel.rowRepresentableEditDescriptors
} }

@ -1,5 +1,6 @@
package net.pokeranalytics.android.ui.fragment.components.bottomsheet package net.pokeranalytics.android.ui.fragment.components.bottomsheet
import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -65,6 +66,7 @@ class BottomSheetTableSizeGridFragment : BottomSheetFragment(), StaticRowReprese
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
this.context?.let { this.context?.let {

@ -1,6 +1,7 @@
package net.pokeranalytics.android.ui.fragment.data package net.pokeranalytics.android.ui.fragment.data
import android.app.Activity.RESULT_OK import android.app.Activity.RESULT_OK
import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
@ -85,6 +86,7 @@ class BankrollDataFragment : EditableDataFragment(), StaticRowRepresentableDataS
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
return when (row) { return when (row) {
@ -107,7 +109,7 @@ class BankrollDataFragment : EditableDataFragment(), StaticRowRepresentableDataS
val rate = this.bankroll.currency?.rate ?: 1.0 val rate = this.bankroll.currency?.rate ?: 1.0
rate.toRate() rate.toRate()
} }
else -> super.stringForRow(row, 0) else -> super.stringForRow(row, context, 0)
} }
} }

@ -1,5 +1,6 @@
package net.pokeranalytics.android.ui.fragment.data package net.pokeranalytics.android.ui.fragment.data
import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -122,11 +123,12 @@ class CustomFieldDataFragment : EditableDataFragment(), StaticRowRepresentableDa
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
return when (row) { return when (row) {
SimpleRow.NAME -> if (customField.name.isNotEmpty()) customField.name else NULL_TEXT SimpleRow.NAME -> if (customField.name.isNotEmpty()) customField.name else NULL_TEXT
else -> super.stringForRow(row, 0) else -> super.stringForRow(row, context, 0)
} }
} }

@ -1,5 +1,6 @@
package net.pokeranalytics.android.ui.fragment.data package net.pokeranalytics.android.ui.fragment.data
import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import com.google.android.libraries.places.api.model.PlaceLikelihood import com.google.android.libraries.places.api.model.PlaceLikelihood
@ -66,11 +67,12 @@ class LocationDataFragment : EditableDataFragment(), StaticRowRepresentableDataS
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
return when (row) { return when (row) {
SimpleRow.NAME -> if (location.name.isNotEmpty())location.name else NULL_TEXT SimpleRow.NAME -> if (location.name.isNotEmpty())location.name else NULL_TEXT
else -> return super.stringForRow(row, 0) else -> return super.stringForRow(row, context, 0)
} }
} }

@ -1,6 +1,7 @@
package net.pokeranalytics.android.ui.fragment.data package net.pokeranalytics.android.ui.fragment.data
import android.app.Activity.RESULT_OK import android.app.Activity.RESULT_OK
import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
@ -118,12 +119,13 @@ class PlayerDataFragment : EditableDataFragment(), StaticRowRepresentableDataSou
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
return when (row) { return when (row) {
PlayerRow.NAME -> if (player.name.isNotEmpty()) player.name else NULL_TEXT PlayerRow.NAME -> if (player.name.isNotEmpty()) player.name else NULL_TEXT
PlayerRow.SUMMARY -> if (player.summary.isNotEmpty()) player.summary else NULL_TEXT PlayerRow.SUMMARY -> if (player.summary.isNotEmpty()) player.summary else NULL_TEXT
else -> super.stringForRow(row, 0) else -> super.stringForRow(row, context, 0)
} }
} }

@ -1,5 +1,6 @@
package net.pokeranalytics.android.ui.fragment.data package net.pokeranalytics.android.ui.fragment.data
import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -48,6 +49,7 @@ class TransactionDataFragment : EditableDataFragment(), StaticRowRepresentableDa
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
return when (row) { return when (row) {
@ -56,7 +58,7 @@ class TransactionDataFragment : EditableDataFragment(), StaticRowRepresentableDa
TransactionRow.AMOUNT -> if (this.transaction.amount != 0.0) this.transaction.amount.round() else NULL_TEXT TransactionRow.AMOUNT -> if (this.transaction.amount != 0.0) this.transaction.amount.round() else NULL_TEXT
TransactionRow.COMMENT -> if (this.transaction.comment.isNotEmpty()) this.transaction.comment else NULL_TEXT TransactionRow.COMMENT -> if (this.transaction.comment.isNotEmpty()) this.transaction.comment else NULL_TEXT
TransactionRow.DATE -> this.transaction.date.shortDate() TransactionRow.DATE -> this.transaction.date.shortDate()
else -> super.stringForRow(row, 0) else -> super.stringForRow(row, context, 0)
} }
} }

@ -1,5 +1,6 @@
package net.pokeranalytics.android.ui.fragment.data package net.pokeranalytics.android.ui.fragment.data
import android.content.Context
import net.pokeranalytics.android.model.realm.Transaction import net.pokeranalytics.android.model.realm.Transaction
import net.pokeranalytics.android.model.realm.TransactionType import net.pokeranalytics.android.model.realm.TransactionType
import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource
@ -35,11 +36,12 @@ class TransactionTypeDataFragment : EditableDataFragment(), RowRepresentableData
override fun stringForRow( override fun stringForRow(
row: RowRepresentable, row: RowRepresentable,
context: Context,
tag: Int tag: Int
): String { ): String {
return when (row) { return when (row) {
SimpleRow.NAME -> this.transactionType.name SimpleRow.NAME -> this.transactionType.name
else -> return super.stringForRow(row, 0) else -> return super.stringForRow(row, context, 0)
} }
} }

@ -24,6 +24,7 @@ import net.pokeranalytics.android.ui.adapter.RecyclerAdapter
import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate
import net.pokeranalytics.android.ui.extensions.px import net.pokeranalytics.android.ui.extensions.px
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetType
import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction
import net.pokeranalytics.android.ui.modules.handhistory.model.HHKeyboard import net.pokeranalytics.android.ui.modules.handhistory.model.HHKeyboard
import net.pokeranalytics.android.ui.modules.handhistory.model.HandHistoryRow import net.pokeranalytics.android.ui.modules.handhistory.model.HandHistoryRow
@ -43,7 +44,7 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable, H
STREET(R.layout.row_hand_cards), STREET(R.layout.row_hand_cards),
BLINDS(R.layout.row_hhsettings_blinds), BLINDS(R.layout.row_hhsettings_blinds),
STRADDLE(R.layout.row_hhsettings_straddle), STRADDLE(R.layout.row_hhsettings_straddle),
// COMMENT(R.layout.row_hhsettings_comment), COMMENT(R.layout.row_hhsettings_comments),
PLAYER_SETUP(R.layout.row_hhsettings_player_setup) PLAYER_SETUP(R.layout.row_hhsettings_player_setup)
; ;
@ -85,6 +86,33 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable, H
} }
} }
override val bottomSheetType: BottomSheetType
get() {
return when(this) {
COMMENT -> BottomSheetType.EDIT_TEXT_MULTI_LINES
else -> BottomSheetType.NONE
}
}
override val resId: Int?
get() {
return when(this) {
COMMENT -> R.string.comment
else -> null
}
}
override val imageRes: Int?
get() {
return when(this) {
COMMENT -> R.drawable.picto_comment
else -> null
}
}
override val imageClickable: Boolean?
get() { return true }
} }
class HandHistoryAdapter( class HandHistoryAdapter(
@ -108,6 +136,7 @@ class HandHistoryAdapter(
HandRowType.BLINDS -> RowHandBlinds(layout) HandRowType.BLINDS -> RowHandBlinds(layout)
HandRowType.STRADDLE -> RowHandStraddle(layout) HandRowType.STRADDLE -> RowHandStraddle(layout)
HandRowType.PLAYER_SETUP -> RowHandPlayerSetup(layout) HandRowType.PLAYER_SETUP -> RowHandPlayerSetup(layout)
HandRowType.COMMENT -> RowViewHolder(layout)
} }
} }
@ -177,9 +206,9 @@ class HandHistoryAdapter(
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
super.onBind(position, row, adapter) super.onBind(position, row, adapter)
itemView.smallBlindEditText.setText(adapter.dataSource.stringForRow(row, 0)) itemView.smallBlindEditText.setText(adapter.dataSource.stringForRow(row, itemView.context, 0))
itemView.bigBlindEditText.setText(adapter.dataSource.stringForRow(row, 1)) itemView.bigBlindEditText.setText(adapter.dataSource.stringForRow(row, itemView.context, 1))
itemView.anteEditText.setText(adapter.dataSource.stringForRow(row, 2)) itemView.anteEditText.setText(adapter.dataSource.stringForRow(row, itemView.context, 2))
itemView.bbAnteSwitch.isChecked = adapter.dataSource.isSelected(position, row, 0) itemView.bbAnteSwitch.isChecked = adapter.dataSource.isSelected(position, row, 0)
val sbSelected = adapter.dataSource.isSelected(position, row, 0) val sbSelected = adapter.dataSource.isSelected(position, row, 0)
@ -490,8 +519,8 @@ class HandHistoryAdapter(
// itemView.positionsChipGroup // itemView.positionsChipGroup
itemView.handEditText.setText(adapter.dataSource.stringForRow(row, 0)) itemView.handEditText.setText(adapter.dataSource.stringForRow(row, itemView.context, 0))
itemView.stackEditText.setText(adapter.dataSource.stringForRow(row, 1)) itemView.stackEditText.setText(adapter.dataSource.stringForRow(row, itemView.context, 1))
} }

@ -17,9 +17,12 @@ import net.pokeranalytics.android.model.realm.handhistory.Card
import net.pokeranalytics.android.model.realm.handhistory.HandHistory import net.pokeranalytics.android.model.realm.handhistory.HandHistory
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate
import net.pokeranalytics.android.ui.fragment.components.RealmFragment import net.pokeranalytics.android.ui.fragment.components.RealmFragment
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetFragment
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetType
import net.pokeranalytics.android.ui.modules.handhistory.model.* import net.pokeranalytics.android.ui.modules.handhistory.model.*
import net.pokeranalytics.android.ui.modules.handhistory.views.KeyboardListener import net.pokeranalytics.android.ui.modules.handhistory.views.KeyboardListener
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.SmoothScrollLinearLayoutManager import net.pokeranalytics.android.ui.view.SmoothScrollLinearLayoutManager
import net.pokeranalytics.android.util.extensions.findById import net.pokeranalytics.android.util.extensions.findById
import timber.log.Timber import timber.log.Timber
@ -211,10 +214,21 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
override fun onRowSelected(position: Int, row: RowRepresentable, tag: Int) { override fun onRowSelected(position: Int, row: RowRepresentable, tag: Int) {
super.onRowSelected(position, row, tag) super.onRowSelected(position, row, tag)
Timber.d("onRowSelected: $position, tag = $tag, row = $row")
if (!this.model.isEdited) { if (!this.model.isEdited) {
return return
} }
when (row.bottomSheetType) {
BottomSheetType.NONE -> {}
else -> {
val editDescriptors = listOf(RowRepresentableEditDescriptor(this.model.handHistory.comment, R.string.comment))
BottomSheetFragment.create(this.fragmentManager, row, this, editDescriptors)
return
}
}
this.model.selectionLiveData.value?.index?.let { oldIndex -> this.model.selectionLiveData.value?.index?.let { oldIndex ->
refreshCells(oldIndex) refreshCells(oldIndex)
} }
@ -223,21 +237,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
this.model.selectionLiveData.value = HHSelection(position, tag) this.model.selectionLiveData.value = HHSelection(position, tag)
// val keyboard = (row as HandHistoryRow).keyboardForTag(tag)
// if (keyboard == HHKeyboard.ACTION) {
// configureActionKeyboard()
// }
// this.keyboard.show(keyboard)
// Timber.d("row $position selected, show keyboard = $keyboard")
}
private fun configureActionKeyboard() {
val availableActions = this.model.availableActions()
this.keyboard.setAvailableAction(availableActions)
val positions = this.model.positionsToAct()
this.keyboard.setPositions(positions)
} }
override fun onRowDeselected(position: Int, row: RowRepresentable) { override fun onRowDeselected(position: Int, row: RowRepresentable) {
@ -247,6 +246,10 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
override fun onRowValueChanged(value: Any?, row: RowRepresentable) { override fun onRowValueChanged(value: Any?, row: RowRepresentable) {
when (row) { when (row) {
HandRowType.COMMENT -> {
this.model.handHistory.comment = value as? String
refreshCells(this.model.indexOfRowRepresentable(row))
}
is ComputedAction -> { is ComputedAction -> {
this.model.currentAmount = value as String this.model.currentAmount = value as String
} }
@ -307,6 +310,13 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
this.model.clearAmount() this.model.clearAmount()
} }
private fun configureActionKeyboard() {
val availableActions = this.model.availableActions()
this.keyboard.setAvailableAction(availableActions)
val positions = this.model.positionsToAct()
this.keyboard.setPositions(positions)
}
override fun closeKeyboard() { override fun closeKeyboard() {
this.model.selectionLiveData.value?.index?.let { this.model.selectionLiveData.value?.index?.let {
this.handHistoryAdapter.notifyItemChanged(it) this.handHistoryAdapter.notifyItemChanged(it)

@ -1,5 +1,6 @@
package net.pokeranalytics.android.ui.modules.handhistory.model package net.pokeranalytics.android.ui.modules.handhistory.model
import android.content.Context
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import net.pokeranalytics.android.R import net.pokeranalytics.android.R
@ -171,6 +172,9 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
private fun createRowRepresentation() { private fun createRowRepresentation() {
val rows: MutableList<RowRepresentable> = mutableListOf() val rows: MutableList<RowRepresentable> = mutableListOf()
rows.add(HandRowType.COMMENT)
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.settings, value = "")) rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.settings, value = ""))
rows.add(HandRowType.BLINDS) rows.add(HandRowType.BLINDS)
@ -221,7 +225,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
val firstIndexOfStreet = this.sortedActions.firstOrNull { it.street == street }?.action?.index val firstIndexOfStreet = this.sortedActions.firstOrNull { it.street == street }?.action?.index
?: this.sortedActions.size ?: this.sortedActions.size
val potSize = this.sortedActions.take(firstIndexOfStreet).sumByDouble { it.action.effectiveAmount } val potSize = this.handHistory.anteSum + this.sortedActions.take(firstIndexOfStreet).sumByDouble { it.action.effectiveAmount }
val potString = if (potSize > 0) potSize.formatted() else "" // "" required otherwise random values come up val potString = if (potSize > 0) potSize.formatted() else "" // "" required otherwise random values come up
val headerView = CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = street.resId, value = potString) val headerView = CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = street.resId, value = potString)
@ -500,6 +504,10 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
return this.rowRepresentables[position].viewType return this.rowRepresentables[position].viewType
} }
fun indexOfRowRepresentable(row: RowRepresentable): Int {
return this.rowRepresentables.indexOf(row)
}
override fun isSelected(position: Int, row: RowRepresentable, tag: Int): Boolean { override fun isSelected(position: Int, row: RowRepresentable, tag: Int): Boolean {
val currentSelection = this.selectionLiveData val currentSelection = this.selectionLiveData
@ -525,13 +533,10 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
this.cardSelectionEnded(this.currentSelection.index) this.cardSelectionEnded(this.currentSelection.index)
} }
// fun setBuilderListener(builderListener: BuilderListener) { override fun stringForRow(row: RowRepresentable, context: Context, tag: Int): String {
// this.builder.setBuilderListener(builderListener)
// }
override fun stringForRow(row: RowRepresentable, tag: Int): String {
return when (row) { return when (row) {
HandRowType.COMMENT -> this.handHistory.comment ?: context.getString(R.string.comment)
HandRowType.BLINDS -> { HandRowType.BLINDS -> {
when (tag) { when (tag) {
0 -> this.handHistory.smallBlind?.formatted() ?: "" 0 -> this.handHistory.smallBlind?.formatted() ?: ""

@ -90,23 +90,27 @@ class RowViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Bindabl
// View background // View background
itemView.findViewById<ViewGroup>(R.id.container)?.let { itemView.findViewById<ViewGroup>(R.id.container)?.let {
val enabled = adapter.dataSource.isEnabled(row, 0) // it.setBackgroundColor(itemView.context.getColor(R.color.kaki))
val color = if (enabled) { //
R.color.kaki_light // val enabled = adapter.dataSource.isEnabled(row, 0)
} else { // val color = if (enabled) {
R.color.kaki // R.color.kaki_light
} // } else {
it.setBackgroundColor(itemView.context.getColor(color)) // R.color.kaki
it.isEnabled = enabled // }
// it.setBackgroundColor(itemView.context.getColor(color))
// it.isEnabled = enabled
} }
// Title // Title
itemView.findViewById<AppCompatTextView?>(R.id.title)?.let { itemView.findViewById<AppCompatTextView?>(R.id.title)?.let {
if (row.resId != null) { val title = row.resId?.let { resId ->
it.text = row.localizedTitle(itemView.context) itemView.context.getString(resId)
} else { } ?: run {
it.text = row.getDisplayName(itemView.context) row.getDisplayName(itemView.context)
} }
it.text = title
val color = if (adapter.dataSource.isEnabled(row, 0)) { val color = if (adapter.dataSource.isEnabled(row, 0)) {
R.color.white R.color.white
} else { } else {
@ -185,6 +189,5 @@ class RowViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Bindabl
it.isSelected = adapter.dataSource.isSelected(position, row, 0) it.isSelected = adapter.dataSource.isSelected(position, row, 0)
} }
} }
} }

@ -22,7 +22,7 @@ class BottomSheetViewModel : ViewModel() {
var valueAsPlaceholder: Boolean = false var valueAsPlaceholder: Boolean = false
var isClearable: Boolean = true var isClearable: Boolean = true
var isDeletable: Boolean = false var isDeletable: Boolean = false
var rowRepresentableEditDescriptors: ArrayList<RowRepresentableEditDescriptor>? = null var rowRepresentableEditDescriptors: List<RowRepresentableEditDescriptor>? = null
/** /**
* Storage for a data that has been newly created * Storage for a data that has been newly created

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/action"
android:src="@drawable/picto_comment"
android:layout_width="24dp"
android:layout_height="24dp"
android:tint="@color/green"
android:layout_gravity="center_vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/value"
style="@style/PokerAnalyticsTheme.TextView.RowTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:maxLines="10"
app:layout_constraintStart_toEndOf="@id/action"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."/>
</androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save