@ -8,13 +8,13 @@ import net.pokeranalytics.android.R
import net.pokeranalytics.android.model.TournamentType
import net.pokeranalytics.android.model.extensions.SessionState
import net.pokeranalytics.android.model.extensions.getState
import net.pokeranalytics.android.model.realm.Bankroll
import net.pokeranalytics.android.model.realm.Session
import net.pokeranalytics.android.model.realm.*
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetFragment
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetType
import net.pokeranalytics.android.ui.helpers.DateTimePickerManager
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowRepresentableEditData
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor
import net.pokeranalytics.android.ui.view.RowViewType
import net.pokeranalytics.android.util.extensions.round
@ -193,7 +193,6 @@ enum class SessionRow : RowRepresentable {
when ( this ) {
START _DATE -> DateTimePickerManager . create ( parent . requireContext ( ) , this , parent , dataSource . startDate )
END _DATE -> {
if ( dataSource . startDate == null ) {
Toast . makeText ( parent . context , R . string . session _missing _start _date , Toast . LENGTH _SHORT ) . show ( )
} else {
@ -205,30 +204,74 @@ enum class SessionRow : RowRepresentable {
dataSource . startDate
)
}
}
BANKROLL -> {
BottomSheetFragment . create ( parent . fragmentManager , this , parent , this . editingData ( dataSource ) , false , dataSource . currency )
}
else -> BottomSheetFragment . create (
parent . fragmentManager ,
this ,
parent ,
this . editingData ( dataSource ) ,
currentCurrency = dataSource . currency
)
else -> BottomSheetFragment . newCreate ( this , parent , this . editingData ( dataSource ) )
}
}
private fun editingData ( session : Session ) : ArrayList < RowRepresentableEditDescriptor > ? {
return when ( this ) {
BANKROLL -> {
arrayListOf (
RowRepresentableEditDescriptor ( session . bankroll , data = session . realm . sorted < Bankroll > ( ) as RealmResults < RowRepresentable > )
)
override val valueCanBeClearedWhenEditing : Boolean
get ( ) {
return when ( this ) {
BANKROLL -> false
else -> true
}
}
private fun editingData ( session : Session ) : RowRepresentableEditData ? {
val data = RowRepresentableEditData ( session . currency )
when ( this ) {
BANKROLL -> data . append ( session . bankroll , data = session . realm . sorted < Bankroll > ( ) as RealmResults < RowRepresentable > )
CASHED _OUT , PRIZE -> data . append ( session . result ?. cashout , inputType = InputType . TYPE _CLASS _NUMBER or InputType . TYPE _NUMBER _FLAG _DECIMAL or InputType . TYPE _NUMBER _FLAG _SIGNED )
NET _RESULT -> data . append ( session . result ?. netResult , inputType = InputType . TYPE _CLASS _NUMBER or InputType . TYPE _NUMBER _FLAG _DECIMAL or InputType . TYPE _NUMBER _FLAG _SIGNED )
INITIAL _BUY _IN -> data . append ( session . tournamentEntryFee ?. round ( ) , inputType = InputType . TYPE _CLASS _NUMBER )
BUY _IN -> {
val bb : Double ? = session . cgBigBlind
val fee : Double ? = session . tournamentEntryFee
val ratedBuyin : Double ? = session . result ?. buyin
if ( bb != null ) {
data . append ( 100.0 * bb )
data . append ( 200.0 * bb )
} else if ( fee != null ) {
data . append ( fee )
data . append ( fee * 2.0 )
} else {
data . append ( 0 )
data . append ( 0 )
}
data . append ( ratedBuyin )
data . append ( inputType = InputType . TYPE _CLASS _NUMBER or InputType . TYPE _NUMBER _FLAG _DECIMAL )
data . append ( inputType = InputType . TYPE _CLASS _NUMBER or InputType . TYPE _NUMBER _FLAG _DECIMAL )
}
else -> null
POSITION -> data . append ( session . result ?. tournamentFinalPosition , inputType = InputType . TYPE _CLASS _NUMBER )
PLAYERS -> data . append ( session . tournamentNumberOfPlayers . toString ( ) , inputType = InputType . TYPE _CLASS _NUMBER )
TIPS -> {
val sb : String ? = session . cgSmallBlind ?. round ( )
val bb : String ? = session . cgBigBlind ?. round ( )
val tips : Double ? = session . result ?. tips
data . append ( sb ?: 0.0 )
data . append ( bb ?: 0.0 )
data . append ( tips ?: 0.0 )
data . append ( " " , inputType = InputType . TYPE _CLASS _NUMBER )
data . append ( " " , inputType = InputType . TYPE _CLASS _NUMBER )
}
GAME -> {
data . append ( session . limit )
data . append ( session . game , data = session . realm . sorted < Game > ( ) as RealmResults < RowRepresentable > )
}
BLINDS -> {
data . append ( session . cgSmallBlind ?. round ( ) , R . string . smallblind , InputType . TYPE _CLASS _NUMBER or InputType . TYPE _NUMBER _FLAG _DECIMAL )
data . append ( session . cgBigBlind ?. round ( ) , R . string . bigblind , InputType . TYPE _CLASS _NUMBER or InputType . TYPE _NUMBER _FLAG _DECIMAL )
}
LOCATION -> data . append ( session . location , data = session . realm . sorted < Location > ( ) as RealmResults < RowRepresentable > )
TABLE _SIZE -> data . append ( session . tableSize )
TOURNAMENT _TYPE -> data . append ( session . tournamentType , staticData = TournamentType . values ( ) . map { it } )
TOURNAMENT _NAME -> data . append ( session . tournamentName , data = session . realm . sorted < TournamentName > ( ) as RealmResults < RowRepresentable > )
TOURNAMENT _FEATURE -> data . append ( session . tournamentFeatures , data = session . realm . sorted < TournamentFeature > ( ) as RealmResults < RowRepresentable > )
BREAK _TIME -> data . append ( hint = R . string . in _minutes , inputType = InputType . TYPE _CLASS _NUMBER )
COMMENT -> data . append ( session . comment , R . string . comment )
else -> { }
}
return data
}
@ -343,20 +386,6 @@ enum class SessionRow : RowRepresentable {
val defaultValue : Int ? by map
arrayListOf ( RowRepresentableEditDescriptor ( defaultValue ) )
}
TIPS -> {
val sb : String ? by map
val bb : String ? by map
val tips : Double ? by map
// Disable the buttons with value = 0, add current value & set the 2 edit texts
arrayListOf (
RowRepresentableEditDescriptor ( sb ?: 0.0 ) ,
RowRepresentableEditDescriptor ( bb ?: 0.0 ) ,
RowRepresentableEditDescriptor ( tips ?: 0.0 ) ,
RowRepresentableEditDescriptor ( " " , inputType = InputType . TYPE _CLASS _NUMBER ) ,
RowRepresentableEditDescriptor ( " " , inputType = InputType . TYPE _CLASS _NUMBER )
)
}
TOURNAMENT _TYPE -> {
val defaultValue : Any ? by map
arrayListOf (