|
|
|
@ -8,6 +8,10 @@ import net.pokeranalytics.android.exceptions.PokerAnalyticsException |
|
|
|
import net.pokeranalytics.android.model.filter.Filterable |
|
|
|
import net.pokeranalytics.android.model.filter.Filterable |
|
|
|
import net.pokeranalytics.android.model.filter.QueryCondition |
|
|
|
import net.pokeranalytics.android.model.filter.QueryCondition |
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.fragment.CalendarFragment |
|
|
|
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
import kotlin.collections.ArrayList |
|
|
|
|
|
|
|
import kotlin.collections.HashSet |
|
|
|
|
|
|
|
|
|
|
|
enum class Comparator { |
|
|
|
enum class Comparator { |
|
|
|
DAY_OF_WEEK, |
|
|
|
DAY_OF_WEEK, |
|
|
|
@ -23,6 +27,17 @@ enum class Comparator { |
|
|
|
MONTH_OF_YEAR -> List(12) { index-> QueryCondition.MONTH().apply { setMonth(index+1) } } |
|
|
|
MONTH_OF_YEAR -> List(12) { index-> QueryCondition.MONTH().apply { setMonth(index+1) } } |
|
|
|
DAY_OF_WEEK -> listOf() |
|
|
|
DAY_OF_WEEK -> listOf() |
|
|
|
YEAR -> { |
|
|
|
YEAR -> { |
|
|
|
|
|
|
|
val years = arrayListOf<QueryCondition.YEAR>() |
|
|
|
|
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
|
|
|
|
calendar.time = Date() |
|
|
|
|
|
|
|
val yearNow = calendar.get(Calendar.YEAR) |
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
realm.where<Session>().sort("year", Sort.ASCENDING).findFirst()?.year?.let { |
|
|
|
|
|
|
|
List(yearNow - it ) { index-> QueryCondition.YEAR().apply { setYear(yearNow - index) } } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
realm.close() |
|
|
|
|
|
|
|
years |
|
|
|
|
|
|
|
/* |
|
|
|
val years = arrayListOf<QueryCondition.YEAR>() |
|
|
|
val years = arrayListOf<QueryCondition.YEAR>() |
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
val distinctYears = realm.where<Session>().distinct("year").findAll().sort("year", Sort.DESCENDING) |
|
|
|
val distinctYears = realm.where<Session>().distinct("year").findAll().sort("year", Sort.DESCENDING) |
|
|
|
@ -33,6 +48,7 @@ enum class Comparator { |
|
|
|
} |
|
|
|
} |
|
|
|
realm.close() |
|
|
|
realm.close() |
|
|
|
years |
|
|
|
years |
|
|
|
|
|
|
|
*/ |
|
|
|
} |
|
|
|
} |
|
|
|
else -> throw PokerAnalyticsException.QueryTypeUnhandled |
|
|
|
else -> throw PokerAnalyticsException.QueryTypeUnhandled |
|
|
|
} |
|
|
|
} |
|
|
|
|