|
|
|
|
@ -30,7 +30,9 @@ import net.pokeranalytics.android.ui.modules.filter.FilterActivityRequestCode |
|
|
|
|
import net.pokeranalytics.android.ui.modules.filter.FilterableType |
|
|
|
|
import net.pokeranalytics.android.ui.modules.filter.FiltersActivity |
|
|
|
|
import net.pokeranalytics.android.ui.modules.settings.TransactionFilterActivity |
|
|
|
|
import net.pokeranalytics.android.util.Global |
|
|
|
|
import timber.log.Timber |
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
class StatisticsFragment : FilterableFragment(), RealmAsyncListener { |
|
|
|
|
|
|
|
|
|
@ -73,10 +75,12 @@ class StatisticsFragment : FilterableFragment(), RealmAsyncListener { |
|
|
|
|
this.currentFilterable = FilterableType.SESSION |
|
|
|
|
applyFilter() |
|
|
|
|
|
|
|
|
|
addRealmChangeListener(this, UserConfig::class.java) |
|
|
|
|
addRealmChangeListener(this, ComputableResult::class.java) |
|
|
|
|
addRealmChangeListener(this, Transaction::class.java) |
|
|
|
|
addRealmChangeListener(this, SessionSet::class.java) |
|
|
|
|
if (Global.LAUNCH_ASYNC_LISTENERS) { |
|
|
|
|
addRealmChangeListener(this, UserConfig::class.java) |
|
|
|
|
addRealmChangeListener(this, ComputableResult::class.java) |
|
|
|
|
addRealmChangeListener(this, Transaction::class.java) |
|
|
|
|
addRealmChangeListener(this, SessionSet::class.java) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun initUI() { |
|
|
|
|
@ -165,8 +169,8 @@ class StatisticsFragment : FilterableFragment(), RealmAsyncListener { |
|
|
|
|
CoroutineScope(Dispatchers.Default).launch { |
|
|
|
|
|
|
|
|
|
val async = async { |
|
|
|
|
// val s = Date() |
|
|
|
|
// Timber.d(">>> start...") |
|
|
|
|
val s = Date() |
|
|
|
|
Timber.d(">>> start...") |
|
|
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
realm.refresh() |
|
|
|
|
@ -176,9 +180,9 @@ class StatisticsFragment : FilterableFragment(), RealmAsyncListener { |
|
|
|
|
|
|
|
|
|
realm.close() |
|
|
|
|
|
|
|
|
|
// val e = Date() |
|
|
|
|
// val duration = (e.time - s.time) / 1000.0 |
|
|
|
|
// Timber.d(">>> ended in $duration seconds") |
|
|
|
|
val e = Date() |
|
|
|
|
val duration = (e.time - s.time) / 1000.0 |
|
|
|
|
Timber.d(">>> computations took $duration seconds") |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
async.await() |
|
|
|
|
@ -196,6 +200,9 @@ class StatisticsFragment : FilterableFragment(), RealmAsyncListener { |
|
|
|
|
*/ |
|
|
|
|
private fun createSessionGroupsAndStartCompute(realm: Realm): Report { |
|
|
|
|
|
|
|
|
|
Timber.d(">>> Launch statistics computations") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val filter: Filter? = this.currentFilter(this.requireContext(), realm)?.let { |
|
|
|
|
if (it.filterableType == currentFilterable) { it } else { null } |
|
|
|
|
} |
|
|
|
|
@ -244,8 +251,6 @@ class StatisticsFragment : FilterableFragment(), RealmAsyncListener { |
|
|
|
|
|
|
|
|
|
val tSessionGroup = ComputableGroup(Query(QueryCondition.IsTournament).merge(query), tStats) |
|
|
|
|
|
|
|
|
|
Timber.d(">>>>> Start computations...") |
|
|
|
|
|
|
|
|
|
val options = Calculator.Options() |
|
|
|
|
val computedStats = mutableListOf<Stat>() |
|
|
|
|
computedStats.addAll(allStats) |
|
|
|
|
|