Fixes issues with Year criteria

od
Laurent 6 years ago
parent f72c15c926
commit 73b5fbcc4d
  1. 4
      app/src/main/java/net/pokeranalytics/android/model/Criteria.kt

@ -223,10 +223,10 @@ sealed class Criteria(override var uniqueIdentifier: Int) : IntIdentifiable, Row
is Years -> {
val years = arrayListOf<Query>()
val realm = Realm.getDefaultInstance()
val lastSession = realm.where<Session>().sort("startDate", Sort.DESCENDING).findFirst()
val lastSession = realm.where<Session>().isNotNull("startDate").sort("startDate", Sort.DESCENDING).findFirst()
val yearNow = lastSession?.year ?: return years
realm.where<Session>().sort("year", Sort.ASCENDING).findFirst()?.year?.let {
realm.where<Session>().isNotNull("startDate").sort("year", Sort.ASCENDING).findFirst()?.year?.let {
for (index in 0..(yearNow - it)) {
val yearCondition = QueryCondition.AnyYear().apply {
listOfValues = arrayListOf(it + index)

Loading…
Cancel
Save