|
|
|
@ -18,6 +18,7 @@ import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.SessionRow |
|
|
|
import net.pokeranalytics.android.ui.view.SessionRow |
|
|
|
import net.pokeranalytics.android.util.data.sessionDao |
|
|
|
import net.pokeranalytics.android.util.data.sessionDao |
|
|
|
import net.pokeranalytics.android.util.getDuration |
|
|
|
import net.pokeranalytics.android.util.getDuration |
|
|
|
|
|
|
|
import net.pokeranalytics.android.util.round |
|
|
|
import net.pokeranalytics.android.util.short |
|
|
|
import net.pokeranalytics.android.util.short |
|
|
|
import net.pokeranalytics.android.util.toCurrency |
|
|
|
import net.pokeranalytics.android.util.toCurrency |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
@ -149,6 +150,13 @@ open class Session : RealmObject(), SessionInterface, RowRepresentableDataSource |
|
|
|
return startDate.getDuration(context, enDate) |
|
|
|
return startDate.getDuration(context, enDate) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return the formatted blinds |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun getBlinds() : String { |
|
|
|
|
|
|
|
return if (cgSmallBlind == null) "--" else "$${cgSmallBlind?.round()}/${cgBigBlind?.round()}" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Delete the object from realm |
|
|
|
* Delete the object from realm |
|
|
|
* TODO: Cascade delete? |
|
|
|
* TODO: Cascade delete? |
|
|
|
@ -255,7 +263,8 @@ open class Session : RealmObject(), SessionInterface, RowRepresentableDataSource |
|
|
|
override fun stringForRow(row: RowRepresentable): String { |
|
|
|
override fun stringForRow(row: RowRepresentable): String { |
|
|
|
return when (row) { |
|
|
|
return when (row) { |
|
|
|
SessionRow.BUY_IN -> buyin.toCurrency() |
|
|
|
SessionRow.BUY_IN -> buyin.toCurrency() |
|
|
|
SessionRow.BLINDS -> if (cgSmallBlind != null && cgBigBlind != null) "$cgSmallBlind / $cgBigBlind" else "--" |
|
|
|
SessionRow.CASHED_OUT -> result?.cashout?.toCurrency() ?: "--" |
|
|
|
|
|
|
|
SessionRow.BLINDS -> getBlinds() |
|
|
|
SessionRow.GAME -> game?.title ?: "--" |
|
|
|
SessionRow.GAME -> game?.title ?: "--" |
|
|
|
SessionRow.LOCATION -> location?.title ?: "--" |
|
|
|
SessionRow.LOCATION -> location?.title ?: "--" |
|
|
|
SessionRow.BANKROLL -> bankroll?.title ?: "--" |
|
|
|
SessionRow.BANKROLL -> bankroll?.title ?: "--" |
|
|
|
@ -305,6 +314,9 @@ open class Session : RealmObject(), SessionInterface, RowRepresentableDataSource |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.CASHED_OUT -> { |
|
|
|
|
|
|
|
data.add(BottomSheetData(result?.cashout, inputType = InputType.TYPE_CLASS_NUMBER)) |
|
|
|
|
|
|
|
} |
|
|
|
SessionRow.TIPS -> { |
|
|
|
SessionRow.TIPS -> { |
|
|
|
// Disable the buttons with value = 0, add current value & set the 2 edit texts |
|
|
|
// Disable the buttons with value = 0, add current value & set the 2 edit texts |
|
|
|
// TODO: manage tips |
|
|
|
// TODO: manage tips |
|
|
|
@ -345,10 +357,14 @@ open class Session : RealmObject(), SessionInterface, RowRepresentableDataSource |
|
|
|
override fun updateValue(value: Any?, row: RowRepresentable) { |
|
|
|
override fun updateValue(value: Any?, row: RowRepresentable) { |
|
|
|
realm.beginTransaction() |
|
|
|
realm.beginTransaction() |
|
|
|
when (row) { |
|
|
|
when (row) { |
|
|
|
|
|
|
|
|
|
|
|
SessionRow.BUY_IN -> { |
|
|
|
SessionRow.BUY_IN -> { |
|
|
|
val localResult = if (result != null) result as Result else realm.createObject(Result::class.java) |
|
|
|
val localResult = if (result != null) result as Result else realm.createObject(Result::class.java) |
|
|
|
localResult.buyin = value as Double |
|
|
|
localResult.buyin = value as Double? |
|
|
|
|
|
|
|
result = localResult |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.CASHED_OUT -> { |
|
|
|
|
|
|
|
val localResult = if (result != null) result as Result else realm.createObject(Result::class.java) |
|
|
|
|
|
|
|
localResult.cashout = if (value == null) null else (value as String).toDouble() |
|
|
|
result = localResult |
|
|
|
result = localResult |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.TABLE_SIZE -> tableSize = value as Int? |
|
|
|
SessionRow.TABLE_SIZE -> tableSize = value as Int? |
|
|
|
@ -367,6 +383,12 @@ open class Session : RealmObject(), SessionInterface, RowRepresentableDataSource |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
null |
|
|
|
null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cgBigBlind?.let { |
|
|
|
|
|
|
|
if (cgSmallBlind == null || cgSmallBlind == 0.0) { |
|
|
|
|
|
|
|
cgSmallBlind = it / 2.0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//TODO: Update |
|
|
|
//TODO: Update |
|
|
|
SessionRow.START_DATE -> if (value is Date?) { |
|
|
|
SessionRow.START_DATE -> if (value is Date?) { |
|
|
|
|