|
|
|
|
@ -18,6 +18,7 @@ import net.pokeranalytics.android.calculus.ComputedResults |
|
|
|
|
import net.pokeranalytics.android.calculus.Stat |
|
|
|
|
import net.pokeranalytics.android.model.comparison.Comparator |
|
|
|
|
import net.pokeranalytics.android.model.comparison.combined |
|
|
|
|
import net.pokeranalytics.android.ui.activity.CalendarDetailsActivity |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
|
|
|
|
@ -35,8 +36,6 @@ import java.util.* |
|
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRepresentableDataSource, RowRepresentableDelegate { |
|
|
|
|
|
|
|
|
|
private enum class SessionType { |
|
|
|
|
@ -69,6 +68,7 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep |
|
|
|
|
private var rows: ArrayList<CustomizableRowRepresentable> = ArrayList() |
|
|
|
|
private var sortedMonthlyReports: SortedMap<Date, ComputedResults> = HashMap<Date, ComputedResults>().toSortedMap() |
|
|
|
|
private var sortedYearlyReports: SortedMap<Date, ComputedResults> = HashMap<Date, ComputedResults>().toSortedMap() |
|
|
|
|
private var datesForRows: HashMap<CustomizableRowRepresentable, Date> = HashMap() |
|
|
|
|
|
|
|
|
|
private var currentSessionType = SessionType.ALL |
|
|
|
|
private var currentTimeFilter = TimeFilter.MONTH |
|
|
|
|
@ -93,7 +93,8 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
|
|
|
|
//toast("Open $row") |
|
|
|
|
Timber.d("Open ${datesForRows[row]}") |
|
|
|
|
CalendarDetailsActivity.newInstance(requireContext()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun sessionsChanged() { |
|
|
|
|
@ -304,6 +305,7 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep |
|
|
|
|
|
|
|
|
|
val startDate = Date() |
|
|
|
|
|
|
|
|
|
datesForRows.clear() |
|
|
|
|
rows.clear() |
|
|
|
|
|
|
|
|
|
when (currentTimeFilter) { |
|
|
|
|
@ -323,14 +325,16 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sortedMonthlyReports[date]?.computedStat(currentStat)?.let { computedStat -> |
|
|
|
|
rows.add( |
|
|
|
|
CustomizableRowRepresentable( |
|
|
|
|
customViewType = RowViewType.TITLE_VALUE_ARROW, |
|
|
|
|
title = date.getDateMonth(), |
|
|
|
|
computedStat = computedStat, |
|
|
|
|
isSelectable = true |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
val row = CustomizableRowRepresentable( |
|
|
|
|
customViewType = RowViewType.TITLE_VALUE_ARROW, |
|
|
|
|
title = date.getDateMonth(), |
|
|
|
|
computedStat = computedStat, |
|
|
|
|
isSelectable = true |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
rows.add(row) |
|
|
|
|
datesForRows.put(row, date) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -339,14 +343,15 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope, StaticRowRep |
|
|
|
|
TimeFilter.YEAR -> { |
|
|
|
|
sortedYearlyReports.keys.forEach { date -> |
|
|
|
|
sortedYearlyReports[date]?.computedStat(currentStat)?.let { computedStat -> |
|
|
|
|
rows.add( |
|
|
|
|
CustomizableRowRepresentable( |
|
|
|
|
customViewType = RowViewType.TITLE_VALUE_ARROW, |
|
|
|
|
title = date.getDateYear(), |
|
|
|
|
computedStat = computedStat, |
|
|
|
|
isSelectable = true |
|
|
|
|
) |
|
|
|
|
val row = CustomizableRowRepresentable( |
|
|
|
|
customViewType = RowViewType.TITLE_VALUE_ARROW, |
|
|
|
|
title = date.getDateYear(), |
|
|
|
|
computedStat = computedStat, |
|
|
|
|
isSelectable = true |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
rows.add(row) |
|
|
|
|
datesForRows.put(row, date) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|