Untitled

mail@pastecode.io avatar
unknown
kotlin
a year ago
2.1 kB
2
Indexable
Never
private fun setData() {
        val selectedNewRouteDetailModelList=routeDetailModelList.filter { item -> item.routesList.any { it.ticket != null && it.ticket?.travelled!=true } }
        val rapidoList = selectedNewRouteDetailModelList.filter {
            it.routesList.any {
                it.fareDetail?.client_name.equals(
                   AppConstants.MEDIUM_METRO,true
                ).not()
            }
        }
        var rapidoItem: Route? = null
        val activeList: ArrayList<Route?> = ArrayList()
        rapidoList.forEach {
            activeList.addAll(it.routesList.filter { it.ticket?.is_expired == false })
        }
        if (activeList.isNotEmpty())
            rapidoItem = activeList[0]
        val bookingStatusList = selectedNewRouteDetailModelList.map {
            BookingItem(
                BookingStatus.SUCCESS,
                it.routesList[0].ticket?.client_data?.vehicle_type ?: "",
                route = it.routesList
            )
        }
        if (rapidoItem?.fareDetail?.vehicle_class.equals(AppConstants.MEDIUM_BIKE, true)){
            progressBarHandler(3)
        }else{
            progressBarHandler(5)
        }

        binding.btnCancelBooking.setOnClickListener {
            countDownTimer?.cancel()
            countDownTimer=null
            bottomSheetdialog.dismiss()
        }
        Glide.with(context).asGif().load(R.raw.mid_start).into(binding.imgLoading)
        adapter = BookingStatusAdapter()
        adapter?.setListener(object : RecyclerItemClickListener {
            override fun onItemClick(position: Int, view: View) {
                if (view.id == R.id.btnCancel) {
                        showCancelBottomSheet(rapidoItem)
                }
            }

        })
        binding.rvRouteDetails.adapter = adapter
        adapter?.submitList(bookingStatusList)
        binding.btnCancelBooking.setOnClickListener {
            rideViewModel.cancelBookingRequest()
            countDownTimer?.cancel()
            countDownTimer=null
            bottomSheetdialog.dismiss()
        }

    }