|
|
|
|
@ -5,11 +5,20 @@ import android.view.LayoutInflater |
|
|
|
|
import android.view.View |
|
|
|
|
import android.view.ViewGroup |
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
|
import io.realm.Realm |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_stats.* |
|
|
|
|
import kotlinx.coroutines.* |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
|
|
|
import net.pokeranalytics.android.calculus.Calculator |
|
|
|
|
import net.pokeranalytics.android.calculus.Report |
|
|
|
|
import net.pokeranalytics.android.calculus.Stat |
|
|
|
|
import net.pokeranalytics.android.model.comparison.Comparator |
|
|
|
|
import net.pokeranalytics.android.model.filter.QueryCondition |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.SessionObserverFragment |
|
|
|
|
import java.util.* |
|
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
|
|
|
|
|
|
class CalendarFragment : PokerAnalyticsFragment() { |
|
|
|
|
class CalendarFragment : SessionObserverFragment(), CoroutineScope { |
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
@ -44,8 +53,75 @@ class CalendarFragment : PokerAnalyticsFragment() { |
|
|
|
|
*/ |
|
|
|
|
private fun initData() { |
|
|
|
|
|
|
|
|
|
val comparator = Comparator.MONTH // returns all months |
|
|
|
|
|
|
|
|
|
val conditions = comparator.queryConditions |
|
|
|
|
|
|
|
|
|
conditions.forEach { |
|
|
|
|
|
|
|
|
|
val realm = getRealm() |
|
|
|
|
Calculator.computeStatsWithComparators(realm, conditions = listOf(it), options = Calculator.Options()) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override val coroutineContext: CoroutineContext |
|
|
|
|
get() = Dispatchers.Main |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun launchStatComputation() { |
|
|
|
|
|
|
|
|
|
val comparator = Comparator.MONTH // returns all months |
|
|
|
|
|
|
|
|
|
// val conditions = comparator.queryConditions |
|
|
|
|
val conditions = listOf(QueryCondition.CASH, QueryCondition.TOURNAMENT) |
|
|
|
|
|
|
|
|
|
conditions.forEach { |
|
|
|
|
|
|
|
|
|
val realm = getRealm() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GlobalScope.launch(coroutineContext) { |
|
|
|
|
|
|
|
|
|
var r = Report() |
|
|
|
|
val test = GlobalScope.async { |
|
|
|
|
val s = Date() |
|
|
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
|
|
val report = Calculator.computeStatsWithComparators(realm, conditions = listOf(it), options = Calculator.Options()) |
|
|
|
|
report.results.firstOrNull()?.let { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val isEmpty = it.isEmpty |
|
|
|
|
val statValue = it.computedStat(Stat.NETRESULT)?.value |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// r = createSessionGroupsAndStartCompute(realm) |
|
|
|
|
// report = r |
|
|
|
|
realm.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
test.await() |
|
|
|
|
|
|
|
|
|
if (!isDetached) { |
|
|
|
|
// showResults(r) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Init UI |
|
|
|
|
*/ |
|
|
|
|
|