Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- override fun getCarTrims(
- makeId: String?,
- subModelId: String?,
- anyString: String
- ): Flowable<Pair<Array<String>, MutableList<CarTrimsResponse>>> {
- if (makeId != null) {
- return database.carTrimsDao().getAllByMakeId(makeId).map { result ->
- val carTrimsMutable = result.toMutableList()
- carTrimsMutable.add(
- 0, CarTrimsResponse(
- name = anyString, id = null
- )
- )
- val trimNames = carTrimsMutable.mapNotNull {
- it.name.takeUnless {
- it.isEmpty()
- }
- }.toTypedArray()
- Pair(trimNames, carTrimsMutable)
- }
- } else if (subModelId != null) {
- database.carSubModelsDao().findById(subModelId).map { subModel ->
- database.carTrimsDao().getAllByIds(subModel.trim_ids.map { it.toInt() }
- .toIntArray())
- .map { trims ->
- val carTrimsMutable = trims.toMutableList()
- carTrimsMutable.add(
- 0, CarTrimsResponse(
- name = anyString, id = null
- )
- )
- val trimNames = carTrimsMutable.mapNotNull {
- it.name.takeUnless {
- it.isEmpty()
- }
- }.toTypedArray()
- //RESULT OF INTEREST
- Pair(trimNames, carTrimsMutable)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment