|
|
|
|
@ -76,6 +76,16 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta |
|
|
|
|
val data = row.editingDescriptors(mapOf("pastDays" to pastDays)) |
|
|
|
|
BottomSheetFragment.create(fragmentManager, row, this, data, true) |
|
|
|
|
} |
|
|
|
|
is FilterElementRow.LastGames -> { |
|
|
|
|
val lastGames = if (row.lastGames > 0) row.lastGames.toString() else "" |
|
|
|
|
val data = row.editingDescriptors(mapOf("lastGames" to lastGames)) |
|
|
|
|
BottomSheetFragment.create(fragmentManager, row, this, data, true) |
|
|
|
|
} |
|
|
|
|
is FilterElementRow.LastSessions -> { |
|
|
|
|
val lastSessions = if (row.lastSessions > 0) row.lastSessions.toString() else "" |
|
|
|
|
val data = row.editingDescriptors(mapOf("lastSessions" to lastSessions)) |
|
|
|
|
BottomSheetFragment.create(fragmentManager, row, this, data, true) |
|
|
|
|
} |
|
|
|
|
is FilterElementRow.DurationMoreThan -> { |
|
|
|
|
val hours = if (row.minutes / 60 > 0) (row.minutes / 60).toString() else "" |
|
|
|
|
val minutes = if (row.minutes % 60 > 0) (row.minutes % 60).toString() else "" |
|
|
|
|
@ -89,50 +99,16 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta |
|
|
|
|
BottomSheetFragment.create(fragmentManager, row, this, data, true) |
|
|
|
|
} |
|
|
|
|
else -> { |
|
|
|
|
|
|
|
|
|
val oldRows = ArrayList<RowRepresentable>() |
|
|
|
|
oldRows.addAll(rows) |
|
|
|
|
if (selectedRows.contains(row)) { |
|
|
|
|
selectedRows.remove(row) |
|
|
|
|
} else { |
|
|
|
|
if (row is FilterElementRow) { |
|
|
|
|
row.sectionToExclude?.let { filterSectionToExclude -> |
|
|
|
|
val excludedFilters = selectedRows.filter { |
|
|
|
|
filterSectionToExclude.contains(it.filterSectionRow) |
|
|
|
|
updateRowsSelection(row) |
|
|
|
|
} |
|
|
|
|
excludedFilters.forEach { |
|
|
|
|
selectedRows.remove(it) |
|
|
|
|
rowRepresentableAdapter.refreshRow(it) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
selectedRows.add(row) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
Timber.d("Row: $row") |
|
|
|
|
when (row) { |
|
|
|
|
FilterRow.FROM -> DateTimePickerManager.create(requireContext(), row, this, Date(), onlyDate = true) |
|
|
|
|
FilterRow.TO -> DateTimePickerManager.create(requireContext(), row, this, Date(), onlyDate = true) |
|
|
|
|
FilterRow.PAST_DAYS -> { |
|
|
|
|
val data = row.editingDescriptors(mapOf("defaultValue" to "")) |
|
|
|
|
BottomSheetFragment.create(fragmentManager, row, this, data, null) |
|
|
|
|
} |
|
|
|
|
else -> { |
|
|
|
|
selectedRows.add(row) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
rowRepresentableAdapter.refreshRow(row) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun stringForRow(row: RowRepresentable): String { |
|
|
|
|
return when (row) { |
|
|
|
|
is FilterElementRow.PastDays -> if (row.lastDays > 0) row.lastDays.toString() else NULL_TEXT |
|
|
|
|
is FilterElementRow.LastGames -> if (row.lastGames > 0) row.lastGames.toString() else NULL_TEXT |
|
|
|
|
is FilterElementRow.LastSessions -> if (row.lastSessions > 0) row.lastSessions.toString() else NULL_TEXT |
|
|
|
|
is FilterElementRow.From -> row.date.shortDate() |
|
|
|
|
is FilterElementRow.To -> row.date.shortDate() |
|
|
|
|
is FilterElementRow.TimeFilterElementRow -> row.minutes.toMinutes(requireContext()) |
|
|
|
|
@ -152,6 +128,8 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta |
|
|
|
|
is FilterElementRow.From -> row.date = if (value != null && value is Date) value else Date() |
|
|
|
|
is FilterElementRow.To -> row.date = if (value != null && value is Date) value else Date() |
|
|
|
|
is FilterElementRow.PastDays -> row.lastDays = if (value != null && value is String) value.toInt() else 0 |
|
|
|
|
is FilterElementRow.LastGames -> row.lastGames = if (value != null && value is String) value.toInt() else 0 |
|
|
|
|
is FilterElementRow.LastSessions -> row.lastSessions = if (value != null && value is String) value.toInt() else 0 |
|
|
|
|
is FilterElementRow.TimeFilterElementRow -> { |
|
|
|
|
if (value is ArrayList<*>) { |
|
|
|
|
val hours = try { |
|
|
|
|
@ -172,16 +150,10 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//TODO: Update management like in onRowSelected |
|
|
|
|
if (value != null) { |
|
|
|
|
if (!selectedRows.contains(row)) { |
|
|
|
|
selectedRows.add(row as FilterElementRow) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// Remove the row before updating the selected rows list |
|
|
|
|
selectedRows.remove(row as FilterElementRow) |
|
|
|
|
} |
|
|
|
|
updateRowsSelection(row, value == null) |
|
|
|
|
|
|
|
|
|
rowRepresentableAdapter.refreshRow(row) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun adapterRows(): List<RowRepresentable>? { |
|
|
|
|
@ -245,6 +217,31 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Update rows selection |
|
|
|
|
*/ |
|
|
|
|
private fun updateRowsSelection(row: RowRepresentable, forceDeselection: Boolean = false) { |
|
|
|
|
|
|
|
|
|
if (selectedRows.contains(row) || forceDeselection) { |
|
|
|
|
selectedRows.remove(row) |
|
|
|
|
} else { |
|
|
|
|
if (row is FilterElementRow) { |
|
|
|
|
row.sectionToExclude?.let { filterSectionToExclude -> |
|
|
|
|
val excludedFilters = selectedRows.filter { |
|
|
|
|
filterSectionToExclude.contains(it.filterSectionRow) |
|
|
|
|
} |
|
|
|
|
excludedFilters.forEach { |
|
|
|
|
selectedRows.remove(it) |
|
|
|
|
rowRepresentableAdapter.refreshRow(it) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
selectedRows.add(row) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Update UI |
|
|
|
|
rowRepresentableAdapter.refreshRow(row) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Save data |
|
|
|
|
|