Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val currentFilters = arrayOf(
- Utils.MutablePair(
- getString(R.string.filtering_option_official_dealer),
- false
- ),
- Utils.MutablePair(
- getString(R.string.filtering_option_non_official_dealer),
- false
- ),
- Utils.MutablePair(
- getString(R.string.filtering_option_one_year_lease_duration),
- false
- ),
- Utils.MutablePair(
- getString(R.string.filtering_option_two_year_lease_duration),
- false
- ),
- Utils.MutablePair(
- getString(R.string.filtering_option_three_year_lease_duration),
- false
- )
- )
- val predicates = listOf<(CarLeasingResponse) -> Boolean>(
- { listing ->
- if (currentFilters[0].active) {
- listing.tags != null && listing.tags.isNotEmpty() && listing.tags[0] == getString(
- R.string.filtering_option_official_dealer
- )
- } else {
- false
- }
- }, { listing ->
- if (currentFilters[1].active) {
- listing.tags != null && listing.tags.isNotEmpty() && listing.tags[0] != getString(
- R.string.filtering_option_official_dealer
- )
- } else {
- false
- }
- },
- { listing ->
- if (currentFilters[2].active) {
- listing.lease_duration?.get(0).toString().toInt() == 1
- } else {
- false
- }
- },
- { listing ->
- if (currentFilters[3].active) {
- listing.lease_duration?.get(
- 0
- ).toString().toInt() == 2
- } else {
- false
- }
- },
- { listing ->
- if (currentFilters[4].active) {
- listing.lease_duration?.get(
- 0
- ).toString().toInt() == 3
- } else {
- false
- }
- }
- )
- val filteringOptionsAdapter = FilterResultsRecyclerAdapter(currentFilters) {
- displayLeasingCars(
- ArrayList(
- originalListings.filter { listing ->
- predicates.all { predicate ->
- predicate.invoke(
- listing
- )
- }
- }
- )
- , false
- )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement