|
|
|
|
@ -6,12 +6,13 @@ import io.realm.Sort |
|
|
|
|
import net.pokeranalytics.android.model.realm.Location |
|
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow |
|
|
|
|
import timber.log.Timber |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns all significant parameters concatenated in a String |
|
|
|
|
* Not suitable for display |
|
|
|
|
*/ |
|
|
|
|
fun Session.parameterRepresentation(context: Context) : String { |
|
|
|
|
fun Session.parameterRepresentation(context: Context): String { |
|
|
|
|
var representation = "" |
|
|
|
|
|
|
|
|
|
this.significantFields().forEach { |
|
|
|
|
@ -24,7 +25,7 @@ fun Session.parameterRepresentation(context: Context) : String { |
|
|
|
|
/** |
|
|
|
|
* Returns a list of fields used to determine which kind of session is favorite |
|
|
|
|
*/ |
|
|
|
|
private fun Session.significantFields() : List<SessionRow> { |
|
|
|
|
private fun Session.significantFields(): List<SessionRow> { |
|
|
|
|
when (this.type) { |
|
|
|
|
Session.Type.CASH_GAME.ordinal -> { |
|
|
|
|
return listOf( |
|
|
|
|
@ -75,7 +76,14 @@ class FavoriteSessionFinder { |
|
|
|
|
*/ |
|
|
|
|
fun copyParametersFromFavoriteSession(newSession: Session, location: Location?, context: Context) { |
|
|
|
|
|
|
|
|
|
val favoriteSession = FavoriteSessionFinder.favoriteSession(newSession.type, location, newSession.realm, context) |
|
|
|
|
val favoriteSession = |
|
|
|
|
FavoriteSessionFinder.favoriteSession(newSession.type, location, newSession.realm, context) |
|
|
|
|
|
|
|
|
|
Timber.d(">>> fav null? = ${favoriteSession == null}") |
|
|
|
|
|
|
|
|
|
Timber.d(">>> game = ${favoriteSession?.game?.name}") |
|
|
|
|
Timber.d(">>> bb = ${favoriteSession?.cgBigBlind?.toString()}") |
|
|
|
|
Timber.d(">>> duration = ${favoriteSession?.netDuration}") |
|
|
|
|
|
|
|
|
|
favoriteSession?.let { fav -> |
|
|
|
|
|
|
|
|
|
@ -99,9 +107,9 @@ class FavoriteSessionFinder { |
|
|
|
|
/** |
|
|
|
|
* Determines the favorite session given a [sessionType] and an optional [location] |
|
|
|
|
*/ |
|
|
|
|
fun favoriteSession(sessionType: Int, location: Location?, realm: Realm, context: Context) : Session? { |
|
|
|
|
fun favoriteSession(sessionType: Int, location: Location?, realm: Realm, context: Context): Session? { |
|
|
|
|
|
|
|
|
|
val lastSessionsQuery = realm.where(Session::class.java).equalTo("type", sessionType) |
|
|
|
|
val lastSessionsQuery = realm.where(Session::class.java).isNotNull("endDate").equalTo("type", sessionType) |
|
|
|
|
if (location != null) { |
|
|
|
|
lastSessionsQuery.equalTo("location.id", location.id) |
|
|
|
|
} |
|
|
|
|
@ -110,7 +118,7 @@ class FavoriteSessionFinder { |
|
|
|
|
.limit(FAVORITE_SIGNIFICANT_SESSIONS) |
|
|
|
|
.findAll() |
|
|
|
|
|
|
|
|
|
val counters= hashMapOf<String, Counter>() |
|
|
|
|
val counters = hashMapOf<String, Counter>() |
|
|
|
|
lastSessions.forEach { session -> |
|
|
|
|
val representation = session.parameterRepresentation(context) |
|
|
|
|
val counter = counters[representation] |
|
|
|
|
|