Small fixes

feature/top10
Laurent 7 years ago
parent 4388d4825a
commit c3b3fb6cbc
  1. 6
      app/src/main/java/net/pokeranalytics/android/PokerAnalyticsApplication.kt
  2. 2
      app/src/main/java/net/pokeranalytics/android/calculus/Computable.kt
  3. 2
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  4. 2
      app/src/main/java/net/pokeranalytics/android/model/realm/SessionSet.kt
  5. 28
      app/src/main/java/net/pokeranalytics/android/model/realm/TimeFrame.kt
  6. 4
      app/src/main/java/net/pokeranalytics/android/model/utils/SessionSetManager.kt
  7. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/HistoryFragment.kt
  8. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/StatsFragment.kt
  9. 6
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/SessionObserverFragment.kt
  10. 1
      app/src/main/res/layout/row_session_view.xml

@ -46,7 +46,7 @@ class PokerAnalyticsApplication : Application() {
val realm: Realm = Realm.getDefaultInstance()
// Add observer on session time frame changes
this.sessions = realm.where(Session::class.java).findAll() // monitor session deletions
// this.sessions?.addChangeListener { _, changeSet ->
// this.endedSessions?.addChangeListener { _, changeSet ->
/*
val deletedSessions =
realm.where(Session::class.java).`in`("id", changeSet.deletions.toTypedArray()).findAll()
@ -63,7 +63,7 @@ class PokerAnalyticsApplication : Application() {
this.createDefaultData()
if (BuildConfig.DEBUG) {
// this.createFakeSessions() // debug
this.createFakeSessions() // debug
}
}
@ -133,7 +133,7 @@ class PokerAnalyticsApplication : Application() {
val realm = Realm.getDefaultInstance()
// Test sessions
// Test endedSessions
val sessions = realm.where<Session>().findAll()
if (sessions.size < 10) {
for (index in 0..50) {

@ -33,7 +33,7 @@ class SessionGroup(name: String, sessions: List<SessionInterface>, stats: List<S
var name: String = name
/**
* The list of sessions to compute
* The list of endedSessions to compute
*/
var sessions: List<SessionInterface> = sessions

@ -115,7 +115,7 @@ open class Session : RealmObject(), SessionInterface, Savable, StaticRowRepresen
// value?.let { it.notifySessionDateChange(this) }
// }
// The time frame sessionGroup, which can contain multiple sessions
// The time frame sessionGroup, which can contain multiple endedSessions
override var sessionSet: SessionSet? = null
// the date of creation of the app

@ -51,7 +51,7 @@ open class SessionSet : RealmObject(), Timed {
// var timeFrame: TimeFrame? = null
/**
* The list of sessions associated with this set
* The list of endedSessions associated with this set
*/
@LinkingObjects("sessionSet")
val sessions: RealmResults<Session>? = null

@ -55,11 +55,11 @@
//
// // Session
// @LinkingObjects("timeFrame")
// private val sessions: RealmResults<Session>? = null // we should have only one session
// private val endedSessions: RealmResults<Session>? = null // we should have only one session
//
// @Ignore
// var session: Session? = null
// get() = if (this.sessions != null && this.sessions.isEmpty()) null else this.sessions?.first()
// get() = if (this.endedSessions != null && this.endedSessions.isEmpty()) null else this.endedSessions?.first()
//
// // Group
// @LinkingObjects("timeFrame")
@ -195,21 +195,21 @@
// var timeFrame: TimeFrame = sessionSet.timeFrame!! // tested in the query
//// timeFrame.setDate(this.startDate, this.endDate)
//
// val sisterSessions = sessionSet.sessions!! // shouldn't crash ever
// val sisterSessions = sessionSet.endedSessions!! // shouldn't crash ever
//
// // if we have only one session in the set and that it corresponds to the set
// if (sessionSet.sessions?.size == 1 && sessionSet.sessions?.first() == owner) {
// if (sessionSet.endedSessions?.size == 1 && sessionSet.endedSessions?.first() == owner) {
// timeFrame.setDate(this.startDate, this.endDate)
// } else { // there are 2+ sessions to manage and possible splits
// } else { // there are 2+ endedSessions to manage and possible splits
//
// val endDate = this.endDate
//
// // case where all sessions are over but the set is not, we might have a split, so we delete the set and save everything again
// // case where all endedSessions are over but the set is not, we might have a split, so we delete the set and save everything again
// if (endDate != null && sisterSessions.all { it.timeFrame?.endDate != null } && timeFrame.endDate == null) {
// var sessions = mutableListOf<Session>(owner)
// sessionSet.sessions?.forEach { sessions.add(it) }
// var endedSessions = mutableListOf<Session>(owner)
// sessionSet.endedSessions?.forEach { endedSessions.add(it) }
// sessionSet.deleteFromRealm()
// sessions.forEach { it.timeFrame?.notifySessionDateChange(it) }
// endedSessions.forEach { it.timeFrame?.notifySessionDateChange(it) }
// } else {
//
// if (this.startDate.before(timeFrame.startDate)) {
@ -259,10 +259,10 @@
//
// }
//
// // get all sessions from sets
// var sessions = mutableSetOf<Session>()
// // get all endedSessions from sets
// var endedSessions = mutableSetOf<Session>()
// sessionSets.forEach { set ->
// set.sessions?.asIterable()?.let { sessions.addAll(it) }
// set.endedSessions?.asIterable()?.let { endedSessions.addAll(it) }
// }
//
// // delete all sets
@ -279,8 +279,8 @@
// // Add the session linked to this timeframe to the new sessionGroup
// owner.sessionSet = set
//
// // Add all orphan sessions
// sessions.forEach { it.sessionSet = set }
// // Add all orphan endedSessions
// endedSessions.forEach { it.sessionSet = set }
// Timber.d("netDuration 3 = : ${set.timeFrame?.netDuration}")
//
// }

@ -91,7 +91,7 @@ class SessionSetManager {
}
}
// get all sessions from sets
// get all endedSessions from sets
val sessions = mutableSetOf<Session>()
sessionSets.forEach { set ->
set.sessions?.asIterable()?.let { sessions.addAll(it) }
@ -108,7 +108,7 @@ class SessionSetManager {
// Add the session linked to this timeframe to the new sessionGroup
session.sessionSet = set
// Add all orphan sessions
// Add all orphan endedSessions
sessions.forEach { it.sessionSet = set }
// Timber.d("netDuration 3 = : ${set.timeFrame?.netDuration}")

@ -67,7 +67,7 @@ class HistoryFragment : PokerAnalyticsFragment(), LiveRowRepresentableDataSource
super.onResume()
//rows.clear()
//sessions.addAll(getRealm().copyFromRealm(realmSessions))
//endedSessions.addAll(getRealm().copyFromRealm(realmSessions))
createSessionsHeaders()
}
@ -105,7 +105,7 @@ class HistoryFragment : PokerAnalyticsFragment(), LiveRowRepresentableDataSource
}
/**
* Create the sessions headers
* Create the endedSessions headers
*/
private fun createSessionsHeaders() {

@ -107,7 +107,7 @@ class StatsFragment : SessionObserverFragment(), StaticRowRepresentableDataSourc
val cgSessions = mutableListOf<Session>()
val tSessions = mutableListOf<Session>()
super.sessions.forEach { session ->
super.endedSessions.forEach { session ->
if (session.isCashGame()) {
cgSessions.add(session)
} else {
@ -116,7 +116,7 @@ class StatsFragment : SessionObserverFragment(), StaticRowRepresentableDataSourc
}
val allStats: List<Stat> = listOf(Stat.NETRESULT, Stat.HOURLY_RATE, Stat.AVERAGE, Stat.NUMBER_OF_SETS, Stat.AVERAGE_DURATION, Stat.DURATION)
val allSessionGroup = SessionGroup(getString(R.string.all), super.sessions, allStats)
val allSessionGroup = SessionGroup(getString(R.string.all), super.endedSessions, allStats)
val cgStats: List<Stat> = listOf(Stat.NETRESULT, Stat.HOURLY_RATE, Stat.NET_BB_PER_100_HANDS, Stat.HOURLY_RATE_BB, Stat.AVERAGE, Stat.STANDARD_DEVIATION_HOURLY, Stat.WIN_RATIO, Stat.NUMBER_OF_GAMES, Stat.AVERAGE_BUYIN)
val cgSessionGroup = SessionGroup(getString(R.string.cash_game), cgSessions, cgStats)
val tStats: List<Stat> = listOf(Stat.NETRESULT, Stat.HOURLY_RATE, Stat.ROI, Stat.WIN_RATIO, Stat.NUMBER_OF_GAMES, Stat.AVERAGE_BUYIN)

@ -6,12 +6,12 @@ import net.pokeranalytics.android.model.realm.Session
open class SessionObserverFragment : PokerAnalyticsFragment() {
val sessions: RealmResults<Session>
val endedSessions: RealmResults<Session>
init {
val realm = Realm.getDefaultInstance()
this.sessions = realm.where(Session::class.java).isNotNull("endDate").findAll()
this.sessions.addChangeListener { _, _ ->
this.endedSessions = realm.where(Session::class.java).isNotNull("endDate").findAll()
this.endedSessions.addChangeListener { _, _ ->
this.sessionsChanged()
}
}

@ -86,7 +86,6 @@
android:textAllCaps="true"
android:textColor="@color/kaki_lighter"
android:textSize="12sp"
android:visibility="gone"
tools:text="4:21"
tools:visibility="visible" />

Loading…
Cancel
Save