fix issue with filter selection

feature/top10
Razmig Sarkissian 7 years ago
parent 3dc8384e4c
commit cd00e9b45a
  1. 6
      app/src/main/java/net/pokeranalytics/android/model/realm/Filter.kt
  2. 15
      app/src/main/java/net/pokeranalytics/android/ui/fragment/FilterDetailsFragment.kt

@ -93,6 +93,12 @@ open class Filter : RealmObject() {
}
}
fun remove(filterCategoryRow: FilterCategoryRow) {
val sections = filterCategoryRow.filterSectionRows.map { it.name }
val savedSections = filterConditions.filter { sections.contains(it.sectionName) }
this.filterConditions.removeAll(savedSections)
}
fun countBy(filterCategoryRow: FilterCategoryRow): Int {
val sections = filterCategoryRow.filterSectionRows.map { it.name }
println("list of sections $sections")

@ -38,14 +38,14 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresent
lateinit var parentActivity: PokerAnalyticsActivity
lateinit var rowRepresentableAdapter: RowRepresentableAdapter
private lateinit var primaryKey: String
private lateinit var filterCategoryRow: FilterCategoryRow
private var currentFilter: Filter? = null
private var rows: ArrayList<RowRepresentable> = ArrayList()
private var rowsForFilterSubcategoryRow: HashMap<FilterSectionRow, ArrayList<RowRepresentable>> = HashMap()
private var primaryKey: String? = null
private var filterMenu: Menu? = null
private var filterCategoryRow: FilterCategoryRow? = null
private val selectedRows = ArrayList<QueryCondition>()
private var isUpdating = false
private var shouldOpenKeyboard = true
@ -174,17 +174,14 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresent
*/
private fun initData() {
primaryKey?.let {
currentFilter = Filter.getFilterBydId(getRealm(), it)
}
currentFilter = Filter.getFilterBydId(getRealm(), primaryKey)
filterCategoryRow?.let {
this.appBar.toolbar.title = it.localizedTitle(requireContext())
this.appBar.toolbar.title = filterCategoryRow.localizedTitle(requireContext())
this.rows.clear()
this.rowsForFilterSubcategoryRow.clear()
this.rows.addAll(it.filterElements)
this.rows.addAll(filterCategoryRow.filterElements)
this.rows.forEach { element ->
if (element is QueryCondition && currentFilter?.contains(element) == true) {
@ -195,7 +192,6 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresent
this.rowRepresentableAdapter = RowRepresentableAdapter(this, this)
this.recyclerView.adapter = rowRepresentableAdapter
}
}
/**
@ -238,6 +234,7 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresent
val realm = getRealm()
realm.beginTransaction()
currentFilter?.remove(filterCategoryRow)
currentFilter?.createOrUpdateFilterConditions(selectedRows)
realm.commitTransaction()

Loading…
Cancel
Save