diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/CalendarFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/CalendarFragment.kt index 40056063..b11bb28f 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/fragment/CalendarFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/CalendarFragment.kt @@ -13,7 +13,6 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch -import net.pokeranalytics.android.R import net.pokeranalytics.android.calculus.Calculator import net.pokeranalytics.android.calculus.ComputedResults import net.pokeranalytics.android.calculus.Stat @@ -36,6 +35,8 @@ import java.util.* import kotlin.coroutines.CoroutineContext + + class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRepresentableDataSource, RowRepresentableDelegate { private enum class SessionType { @@ -76,7 +77,7 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep // Life Cycle override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return inflater.inflate(R.layout.fragment_calendar, container, false) + return inflater.inflate(net.pokeranalytics.android.R.layout.fragment_calendar, container, false) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -95,6 +96,9 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep //toast("Open $row") } + override fun sessionsChanged() { + launchStatComputation() + } // Business @@ -138,7 +142,7 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep }) // Manage session type filter - filterSessionAll.setOnCheckedChangeListener { buttonView, isChecked -> + filterSessionAll.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { currentSessionType = SessionType.ALL filterSessionCash.isChecked = false @@ -148,7 +152,7 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep filterSessionAll.isChecked = true } } - filterSessionCash.setOnCheckedChangeListener { buttonView, isChecked -> + filterSessionCash.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { currentSessionType = SessionType.CASH filterSessionAll.isChecked = false @@ -158,7 +162,7 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep filterSessionCash.isChecked = true } } - filterSessionTournament.setOnCheckedChangeListener { buttonView, isChecked -> + filterSessionTournament.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { currentSessionType = SessionType.TOURNAMENT filterSessionAll.isChecked = false @@ -170,7 +174,7 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep } // Manage time filter - filterTimeMonth.setOnCheckedChangeListener { buttonView, isChecked -> + filterTimeMonth.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { currentTimeFilter = TimeFilter.MONTH filterTimeYear.isChecked = false @@ -180,7 +184,7 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep } } - filterTimeYear.setOnCheckedChangeListener { buttonView, isChecked -> + filterTimeYear.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { currentTimeFilter = TimeFilter.YEAR filterTimeMonth.isChecked = false @@ -220,13 +224,13 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep // Compute data per YEAR and MONTH - val monthConditions = when(currentSessionType) { + val monthConditions = when (currentSessionType) { SessionType.ALL -> listOf(Comparator.YEAR, Comparator.MONTH_OF_YEAR).combined() SessionType.CASH -> listOf(Comparator.YEAR, Comparator.MONTH_OF_YEAR, Comparator.CASH).combined() SessionType.TOURNAMENT -> listOf(Comparator.YEAR, Comparator.MONTH_OF_YEAR, Comparator.TOURNAMENT).combined() } - monthConditions.forEach {conditions -> + monthConditions.forEach { conditions -> val report = Calculator.computeStatsWithComparators(realm, conditions = conditions, options = Calculator.Options()) report.results.forEach { computedResults -> if (!computedResults.isEmpty) { @@ -248,7 +252,7 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep calendar.time = Date().startOfYear() // Compute data per YEAR - val yearConditions = when(currentSessionType) { + val yearConditions = when (currentSessionType) { SessionType.ALL -> listOf(Comparator.YEAR).combined() SessionType.CASH -> listOf(Comparator.YEAR, Comparator.CASH).combined() SessionType.TOURNAMENT -> listOf(Comparator.YEAR, Comparator.TOURNAMENT).combined() diff --git a/app/src/main/res/layout-sw320dp/fragment_calendar.xml b/app/src/main/res/layout-sw320dp/fragment_calendar.xml new file mode 100644 index 00000000..1f773978 --- /dev/null +++ b/app/src/main/res/layout-sw320dp/fragment_calendar.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw400dp/fragment_calendar.xml b/app/src/main/res/layout-sw400dp/fragment_calendar.xml new file mode 100644 index 00000000..f12b0457 --- /dev/null +++ b/app/src/main/res/layout-sw400dp/fragment_calendar.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_calendar.xml b/app/src/main/res/layout/fragment_calendar.xml index 42d5029a..c072581c 100644 --- a/app/src/main/res/layout/fragment_calendar.xml +++ b/app/src/main/res/layout/fragment_calendar.xml @@ -18,48 +18,61 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" + android:padding="8dp" android:orientation="horizontal"> + app:chipSpacing="8dp"> + android:text="@string/month"/> + android:text="@string/year"/> + + + + + + + android:checked="true" + android:text="@string/all"/> + android:text="@string/cash_game"/> + android:text="@string/tournament"/>