|
|
|
@ -12,7 +12,9 @@ import net.pokeranalytics.android.model.interfaces.Deletable |
|
|
|
import net.pokeranalytics.android.model.interfaces.DeleteValidityStatus |
|
|
|
import net.pokeranalytics.android.model.interfaces.DeleteValidityStatus |
|
|
|
import net.pokeranalytics.android.model.interfaces.Identifiable |
|
|
|
import net.pokeranalytics.android.model.interfaces.Identifiable |
|
|
|
import net.pokeranalytics.android.ui.interfaces.FilterableType |
|
|
|
import net.pokeranalytics.android.ui.interfaces.FilterableType |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.view.ImageDecorator |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterCategoryRow |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterCategoryRow |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
@ -21,12 +23,12 @@ import java.util.* |
|
|
|
* It contains a list of [FilterCondition] describing the complete query to launch |
|
|
|
* It contains a list of [FilterCondition] describing the complete query to launch |
|
|
|
* The [Filter] is working closely with a [Filterable] interface providing the entity we want the query being launched on |
|
|
|
* The [Filter] is working closely with a [Filterable] interface providing the entity we want the query being launched on |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
open class Filter : RealmObject(), RowRepresentable, Identifiable, Deletable { |
|
|
|
open class Filter : RealmObject(), RowRepresentable, Identifiable, Deletable, ImageDecorator { |
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
|
|
// Create a new instance |
|
|
|
// Create a new instance |
|
|
|
fun newInstance(realm: Realm, filterableType:Int): Filter { |
|
|
|
fun newInstance(realm: Realm, filterableType: Int): Filter { |
|
|
|
val filter = Filter() |
|
|
|
val filter = Filter() |
|
|
|
filter.filterableTypeOrdinal = filterableType |
|
|
|
filter.filterableTypeOrdinal = filterableType |
|
|
|
return filter |
|
|
|
return filter |
|
|
|
@ -68,6 +70,15 @@ open class Filter : RealmObject(), RowRepresentable, Identifiable, Deletable { |
|
|
|
|
|
|
|
|
|
|
|
private var filterableTypeOrdinal: Int? = null |
|
|
|
private var filterableTypeOrdinal: Int? = null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override val viewType: Int |
|
|
|
|
|
|
|
get() = RowViewType.TITLE_VALUE_ACTION.ordinal |
|
|
|
|
|
|
|
override val imageRes: Int? |
|
|
|
|
|
|
|
get() = R.drawable.ic_outline_settings |
|
|
|
|
|
|
|
override val imageTint: Int? |
|
|
|
|
|
|
|
get() = R.color.green |
|
|
|
|
|
|
|
override val imageClickable: Boolean? |
|
|
|
|
|
|
|
get() = true |
|
|
|
|
|
|
|
|
|
|
|
val filterableType: FilterableType |
|
|
|
val filterableType: FilterableType |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
this.filterableTypeOrdinal?.let { |
|
|
|
this.filterableTypeOrdinal?.let { |
|
|
|
@ -84,7 +95,7 @@ open class Filter : RealmObject(), RowRepresentable, Identifiable, Deletable { |
|
|
|
it.groupId |
|
|
|
it.groupId |
|
|
|
} |
|
|
|
} |
|
|
|
.distinct() |
|
|
|
.distinct() |
|
|
|
.forEach { groupId-> |
|
|
|
.forEach { groupId -> |
|
|
|
filterConditionRows |
|
|
|
filterConditionRows |
|
|
|
.filter { |
|
|
|
.filter { |
|
|
|
it.groupId == groupId |
|
|
|
it.groupId == groupId |
|
|
|
@ -121,7 +132,7 @@ open class Filter : RealmObject(), RowRepresentable, Identifiable, Deletable { |
|
|
|
fun contains(filterElementRow: QueryCondition): Boolean { |
|
|
|
fun contains(filterElementRow: QueryCondition): Boolean { |
|
|
|
println("list of saved queries ${filterConditions.map { it.queryCondition.id }}") |
|
|
|
println("list of saved queries ${filterConditions.map { it.queryCondition.id }}") |
|
|
|
println("list of contains ${filterElementRow.id}") |
|
|
|
println("list of contains ${filterElementRow.id}") |
|
|
|
val contained = filterConditions.flatMap{ it.queryCondition.id }.contains(filterElementRow.id.first()) |
|
|
|
val contained = filterConditions.flatMap { it.queryCondition.id }.contains(filterElementRow.id.first()) |
|
|
|
println("list of : $contained") |
|
|
|
println("list of : $contained") |
|
|
|
return contained |
|
|
|
return contained |
|
|
|
} |
|
|
|
} |
|
|
|
|