package com.abbidot.tracker.ui.fragment.data

import android.animation.ValueAnimator
import android.annotation.SuppressLint
import android.content.Context
import android.view.MotionEvent
import android.view.View
import android.view.animation.LinearInterpolator
import android.widget.SeekBar
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.commit
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import com.abbidot.baselibrary.constant.EventName
import com.abbidot.baselibrary.eventbus.XEventBus
import com.abbidot.baselibrary.util.AppUtils
import com.abbidot.baselibrary.util.LogUtil
import com.abbidot.baselibrary.util.Utils
import com.abbidot.tracker.R
import com.abbidot.tracker.adapter.HistoryFenceAdapter
import com.abbidot.tracker.base.BaseDialog
import com.abbidot.tracker.base.BaseFragment
import com.abbidot.tracker.bean.HistoryDataBean
import com.abbidot.tracker.bean.MessageBean
import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.constant.GetResultCallback
import com.abbidot.tracker.databinding.FragmentRouteV3Binding
import com.abbidot.tracker.dialog.ShowCalenderAndTimeDialog
import com.abbidot.tracker.ui.activity.HomeV2Activity
import com.abbidot.tracker.ui.common.map.HistoryDataMapCommon
import com.abbidot.tracker.util.Util
import com.abbidot.tracker.util.ViewUtil
import com.abbidot.tracker.vm.DataDetailViewModel
import com.abbidot.tracker.vm.GeoCoderViewModel
import com.abbidot.tracker.widget.NoClickSlideSeekBar
import com.abbidot.tracker.widget.TypefaceTextView
import kotlinx.coroutines.launch
import kotlin.math.abs


/**
 * 首页轨迹
 * create an instance of this fragment.
 */
class RouteV3Fragment : BaseFragment<FragmentRouteV3Binding>(FragmentRouteV3Binding::inflate) {

    private val mDataDetailViewModel: DataDetailViewModel by viewModels()
    private val mGeoCoderViewModel: GeoCoderViewModel by viewModels()

    private lateinit var mFragment: Fragment

    private var mFromCalenderDialog: ShowCalenderAndTimeDialog? = null
    private var mToCalenderDialog: ShowCalenderAndTimeDialog? = null

    //当前这个页面显示的宠物下标
    private var mCurrentShowPetPos = -1

    //最多只能选择多少天的历史记录
    private val mOnlySelectDay = 7L

    //当前的时间戳
    private var mCurrentTimestamp = 0L
    private var mFromTimestamp = 0L
    private var mToTimestamp = 0L

    //方便保存地理反编译信息
    private var mHistoryDataList = mutableListOf<HistoryDataBean>()
    private val mHistoryDataMapCommon = HistoryDataMapCommon()

    //是否选过自定义日期，没有则再次回到这个页面，刷新取24小时的记录
    private var isSelectCustomDate = false

    //    private var isFirst = true
    private var mProgress = 0

    private lateinit var mHistoryFenceAdapter: HistoryFenceAdapter
    private val mAllHistoryFenceList = mutableListOf<MessageBean>()

    //充值续费或升级返回类型
    private var mRechargeBackType = ConstantInt.SpecialType

    //列表是否滑到顶部展开
    private var isListExpand = false

    //判断是否滑过
    private var isHaveSlide = false

    //手指滑动的y坐标点
    private var mLastY = 0f

    //手指滑动时布局移动高度
    private var mDiffHeight = 0

    //是否上滑
    private var isSlideUp = false

    //布局可以滑的总高度
    private var mTotalHeight = 0

    //底部列表有一个元素的高度+日历的高度
    private var mLastScrollViewHeight = 0

    //选择日期布局的高度（包括有SeekBar的高度）
    private var mCalendarLayoutHaveSeekBarHeight = 0

    //是否是有效滑动
    private var isValidMove = false

//    private lateinit var mTopSlideLayoutManager: TopSlideLayoutManager

    companion object {
        @JvmStatic
        fun newInstance(context: Context) = RouteV3Fragment().apply {
            mContext = context
        }
    }

    @SuppressLint("ClickableViewAccessibility")
    override fun initData() {
        mViewBinding.apply {
            getHomeV2Activity()?.edgeToEdgeAdapterBars(
                root, WindowInsetsCompat.Type.statusBars()
            )
            mFragment = mHistoryDataMapCommon.getMapFragment(
                mContext!!, miHomeRouteAddressViewV3, mGeoCoderViewModel, vsbMapRouteLineV3
            ) {
                mapLoadOk()
            }

            mHistoryFenceAdapter = HistoryFenceAdapter(mContext!!, null)
            ViewUtil.instance.setRecyclerViewVerticalLinearLayout(
                mContext!!, rvMapRouteLineV3FencesList, mHistoryFenceAdapter
            )
//            rvMapRouteLineV3FencesList.let {
//                mTopSlideLayoutManager = TopSlideLayoutManager(
//                    mContext!!, LinearLayoutManager.VERTICAL, false
//                )
//                it.layoutManager = mTopSlideLayoutManager
//                it.adapter = mHistoryFenceAdapter
//            }

            ilHomeRoutePetHeadV3.ivTopPetBtnSmall.visibility = View.GONE
            //设置不可点击状态
            vsbMapRouteLineV3.setStatus(NoClickSlideSeekBar.STATUS.STATUS_SLIDE)

            setOnClickListenerViews(
                llHomeRouteCalendarFromV3,
                llHomeRouteCalendarToV3,
                ilHomeRoutePetHeadV3.homeDataPetHeadSmall.root,
                ilHomeRoutePetHeadV3.homeDataPetNameSmall,
                ivHomeRouteMapTypeBtnV3,
                ivMapRouteLineV3LastBtn,
                ivMapRouteLineV3NextBtn
            )

            llMapRouteLineV3ZoomingLayout.setOnTouchListener { _, event ->
                if (rlMapRouteLineV3TimeLayout.isVisible) {
                    //获取初始高度
                    if (mTotalHeight == 0) {
                        mTotalHeight = cvHomeRouteV3Card.height + svHomeRouteMapScroll.height
                    }
                    if (mLastScrollViewHeight == 0 && mHistoryFenceAdapter.getData().size == 1) {
                        mCalendarLayoutHaveSeekBarHeight = rlHomeRouteCalendarV3Layout.height
                        mLastScrollViewHeight = svHomeRouteMapScroll.height
                    }

                    when (event.action) {
                        MotionEvent.ACTION_DOWN -> {
                            LogUtil.e("ACTION_DOWN")
                            mLastY = event.rawY
                        }

                        MotionEvent.ACTION_MOVE -> {
                            val dy = mLastY - event.rawY
                            if (abs(dy) > 50) {
                                val layoutParams = svHomeRouteMapScroll.layoutParams
                                val diff = (svHomeRouteMapScroll.height + dy).toInt()
                                isSlideUp = dy >= 0.0f
                                if (diff > mLastScrollViewHeight) {
                                    isHaveSlide = true
                                    if (mHistoryFenceAdapter.getData().size != mAllHistoryFenceList.size) {
                                        mHistoryFenceAdapter.setData(mAllHistoryFenceList, true)
                                    }
                                    mDiffHeight = diff
                                    layoutParams.height = diff
                                    svHomeRouteMapScroll.layoutParams = layoutParams
                                    mLastY = event.rawY
                                }
                                isValidMove = true
                            }
                        }

                        MotionEvent.ACTION_UP -> {
                            LogUtil.e("ACTION_UP")
                            if (!isValidMove) return@setOnTouchListener true
                            isValidMove = false
                            if (mDiffHeight > mTotalHeight / 2) {
                                setSeekBarShowHide(false)
                                isListExpand = true
                                if (isSlideUp) {
                                    animateViewHeight(svHomeRouteMapScroll, mTotalHeight)
                                } else {
                                    animateViewHeight(svHomeRouteMapScroll, mTotalHeight / 2)
                                    svHomeRouteMapScroll.postDelayed(
                                        {
                                            //重新设置地图缩放级别
                                            mHistoryDataMapCommon.setLatLngData(mHistoryDataList)
                                        }, 500
                                    )
                                }
                            } else {
                                if (mDiffHeight > mLastScrollViewHeight) {
                                    val height = if (isSlideUp) {
                                        isListExpand = true
                                        setSeekBarShowHide(false)
                                        mTotalHeight / 2
                                    } else {
                                        isListExpand = false
                                        setSeekBarShowHide(true)
                                        if (mHistoryFenceAdapter.getData().size > 1) {
                                            mHistoryFenceAdapter.setData(
                                                mAllHistoryFenceList.subList(
                                                    0, 1
                                                ), true
                                            )
                                        }
                                        mLastScrollViewHeight
                                    }
                                    animateViewHeight(svHomeRouteMapScroll, height)
                                    svHomeRouteMapScroll.postDelayed(
                                        {
                                            //重新设置地图缩放级别
                                            mHistoryDataMapCommon.setLatLngData(mHistoryDataList)
                                        }, 500
                                    )
                                }
                            }
                        }
                    }
                }
                false
            }

            if (AppUtils.isDebug()) {
                ilHomeRoutePetHeadV3.homeDataPetHeadSmall.root.setOnLongClickListener {
                    getHomeV2Activity()?.goToDebugActivity()
                    true
                }
            }
        }

        //解决报错java.lang.IllegalArgumentException
        //No view found for id 0x7f090254 (com.abbidot.tracker:id/fc_home_route_fragment) for fragment HomeMapGoogleMapFragment
        //https://www.jianshu.com/p/9235092f407a
        childFragmentManager.commit {
            add(R.id.fc_home_route_fragment_v3, mFragment)
        }

        initEven()
        initState()
    }

    private fun animateViewHeight(view: View, targetHeight: Int, duration: Long = 300) {
        val animator = ValueAnimator.ofInt(view.height, targetHeight)
        animator.duration = duration // 设置动画持续时间
        animator.interpolator = LinearInterpolator() // 设置插值器
        animator.addUpdateListener { animation ->
            val animatedValue = animation.animatedValue as Int
            val layoutParams = view.layoutParams
            layoutParams.height = animatedValue
            view.layoutParams = layoutParams
        }
        animator.start()
    }

    private fun getHomeV2Activity(): HomeV2Activity? {
        return if (null == activity) {
            LogUtil.e("RouteV2Fragment,getHomeV2Activity,null == activity")
            null
        } else {
            activity as HomeV2Activity
        }
    }

    /**
     * 一开始获取24小时内的数据
     */
    private fun get24HourTime() {
        mCurrentTimestamp = System.currentTimeMillis()
        mViewBinding.apply {
            mFromTimestamp = Utils.getBeforeHowTimestamp(mCurrentTimestamp, 1)
            mToTimestamp = mCurrentTimestamp
            tvHomeRouteCalendarToV3.text =
                Utils.formatTime(mToTimestamp, Utils.DATE_FORMAT_PATTERN_EN13)
            tvHomeRouteCalendarFromV3.text =
                Utils.formatTime(mFromTimestamp, Utils.DATE_FORMAT_PATTERN_EN13)
        }
    }


    private fun initState() {
        mViewBinding.miHomeRouteAddressViewV3.visibility = View.GONE
        mHistoryDataMapCommon.clearAllMarker()
        setSeekBarMax(0)
    }

    private fun initEven() {
        mViewBinding.vsbMapRouteLineV3.setOnSeekBarChangeListener(object :
            SeekBar.OnSeekBarChangeListener {
            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
                if (mProgress == progress) {
                    return
                }
                mProgress = progress
                mViewBinding.miHomeRouteAddressViewV3.visibility = View.GONE
                mHistoryDataMapCommon.slideChanged(progress)
            }

            override fun onStartTrackingTouch(seekBar: SeekBar) {
            }

            override fun onStopTrackingTouch(seekBar: SeekBar) {
                mHistoryDataMapCommon.slideStopChanged(seekBar.progress)
            }
        })
    }

    override fun onResume() {
        super.onResume()
        //续费成功后，不执行
        if (mRechargeBackType == ConstantInt.Type1) {
            return
        }
        getHomeV2Activity()?.apply {
            if (mCurrentShowPetPos == mSelectPetPosition) {
                if (!isSelectCustomDate) {
                    if (mHistoryDataMapCommon.isMapLoadOk()) {
                        get24HourTime()
                        getHistoryDay(mViewBinding.tvHomeRouteCalendarFromV3)
                    }
                }
            } else {
                //其他页面是否选择了宠物
                if (!isSelectCustomDate) get24HourTime()
                showPetNameAndHead(mSelectPetPosition)
            }
            checkNotifyLocationState()
        }
    }

    fun checkNotifyLocationState() {
        getHomeV2Activity()?.apply {
            checkNotifyRefreshLocation(mViewBinding.ilHomeRoutePetHeadV3.homeDataPetNameSmall)
        }
    }

    override fun liveDataObserve() {
        //更新套餐数据
        XEventBus.observe(this, EventName.RefreshPackage) {
            //监听续费成功
            if (mRechargeBackType == ConstantInt.Type0) {
                mRechargeBackType = ConstantInt.Type1
            }
        }

        mDataDetailViewModel.apply {
            mHistoryDetailLive.observe(this@RouteV3Fragment) {
                dealRequestResult(it, object : GetResultCallback {
                    override fun onResult(any: Any) {
                        val data = it.getOrNull()!!
                        setLatLngData(data)
                        getHomeV2Activity()?.let { a ->
                            a.getPet(false)?.let { p ->
                                mAllHistoryFenceList.clear()
                                getHistoryFenceList(
                                    a, p.deviceId, mFromTimestamp / 1000, mToTimestamp / 1000
                                )
                            }
                        }
                    }

                    override fun onRequestError(exceptionCode: String?) {
                        setSeekBarShowHide(false)
                    }
                }, isShowNoDataTip = false)
            }
            mHistoryFenceEvents.observe(this@RouteV3Fragment) {
                dealRequestResult(it, object : GetResultCallback {
                    override fun onResult(any: Any) {
                        it.getOrNull()?.let { d ->
                            if (d.size > 0) {
                                mViewBinding.rlMapRouteLineV3TimeLayout.visibility = View.VISIBLE
                                mAllHistoryFenceList.addAll(d)
                                if (isListExpand) {
                                    mHistoryFenceAdapter.setData(
                                        mAllHistoryFenceList, true
                                    )
                                } else {
                                    mHistoryFenceAdapter.setData(
                                        mAllHistoryFenceList.subList(0, 1), true
                                    )
                                }
                                if (isHaveSlide) {
                                    //判断滑过，从无数据到有数据布局错乱
                                    val layoutParams =
                                        mViewBinding.svHomeRouteMapScroll.layoutParams
                                    if (layoutParams.height < mLastScrollViewHeight) {
                                        layoutParams.height = mLastScrollViewHeight
                                        mViewBinding.svHomeRouteMapScroll.layoutParams =
                                            layoutParams
                                    }
                                }
                            } else {
                                mViewBinding.rlMapRouteLineV3TimeLayout.visibility = View.GONE
                                if (isHaveSlide) {
                                    val lastScrollViewNoListHeight =
                                        mViewBinding.rlHomeRouteCalendarV3Layout.height
                                    val layoutParams =
                                        mViewBinding.svHomeRouteMapScroll.layoutParams
                                    layoutParams.height =
                                        if (mViewBinding.vsbMapRouteLineV3.isVisible) mCalendarLayoutHaveSeekBarHeight
                                        else lastScrollViewNoListHeight
                                    mViewBinding.svHomeRouteMapScroll.layoutParams = layoutParams
                                }
                                isListExpand = false
                            }
                            if (mViewBinding.cvHomeRouteV3Card.height > 0) mViewBinding.svHomeRouteMapScroll.postDelayed(
                                {
                                    //重新设置地图缩放级别
                                    mHistoryDataMapCommon.setLatLngData(mHistoryDataList)
                                }, 200
                            )
                        }
                    }
                }, isShowNoDataTip = false)
            }
        }

        //地理反编译成功返回
        mGeoCoderViewModel.mLatLonAddressLiveData.observe(this) {
            val position = mViewBinding.vsbMapRouteLineV3.progress
            if (mHistoryDataList.size <= position) return@observe
            mHistoryDataList[position].apply {
                //详细位置
                address = it
                val timeString = Utils.formatTime(timeStamp * 1000, Utils.DATE_FORMAT_PATTERN_CN5)
                //更新位置时间
                dayTime = timeString
                mViewBinding.root.postDelayed(
                    {
                        mViewBinding.miHomeRouteAddressViewV3.let { mi ->
                            mi.visibility = View.VISIBLE
                            mi.setShowText(timeString, it)
                        }
                    }, 100
                )
            }
        }
    }

    /**
     * 地图加载好了
     */
    private fun mapLoadOk() {
        if (mCurrentShowPetPos == -1) return
        getHomeV2Activity()?.apply {
            showPetNameAndHead(mSelectPetPosition)
        }
    }

    /**
     * 设置需要更新的标识
     */
    fun setNeedUpdateTag() {
        mCurrentShowPetPos = -1
    }

    /**
     * 显示选择的宠物
     */
    fun showPetNameAndHead(position: Int) {
        getHomeV2Activity()?.apply {
            if (mPetList.size == 0) {
                return
            }
            mCurrentShowPetPos = position

            ViewUtil.instance.selectPetDialogShow(
                mContext,
                mPetList,
                position,
                mViewBinding.ilHomeRoutePetHeadV3.homeDataPetNameSmall,
                mViewBinding.ilHomeRoutePetHeadV3.homeDataPetHeadSmall.appHeadImage
            )

            if (mHistoryDataMapCommon.isMapLoadOk()) {
                getHistoryDay(mViewBinding.tvHomeRouteCalendarFromV3)
            }
        }
    }

    private fun setLatLngData(data: MutableList<HistoryDataBean>) {
        viewLifecycleOwner.lifecycleScope.launch {
            mHistoryDataList = data
            getHomeV2Activity()?.getPet(false)?.let {
                mHistoryDataMapCommon.setPetBean(it)
            }

            if (isResumed) {
                getHomeV2Activity()?.getPet()?.let { pet ->
                    if (Util.checkPackageLimit(getHomeV2Activity()!!, pet.deviceId)) {
                        mRechargeBackType = pet.availableOrder
                        mHistoryDataMapCommon.setPetUserLatLng()
                        return@launch
                    }
                }
            }
            if (data.size == 0) {
                setSeekBarShowHide(false)
                mHistoryDataMapCommon.setPetUserLatLng()
                return@launch
            }

            setSeekBarShowHide(true)
            val max = data.size - 1
            setSeekBarMax(max)

            mHistoryDataMapCommon.setLatLngData(data)
        }
    }

    /**
     * 设置SeekBar相关布局隐藏显示
     */
    private fun setSeekBarShowHide(show: Boolean) {
        mViewBinding.apply {
            if (show && !isListExpand && mHistoryDataList.isNotEmpty()) {
                vsbMapRouteLineV3.visibility = View.VISIBLE
                ivMapRouteLineV3LastBtn.visibility = View.VISIBLE
                ivMapRouteLineV3NextBtn.visibility = View.VISIBLE
            } else {
                vsbMapRouteLineV3.visibility = View.GONE
                ivMapRouteLineV3LastBtn.visibility = View.GONE
                ivMapRouteLineV3NextBtn.visibility = View.GONE
            }
        }
    }

    private fun setSeekBarMax(max: Int) {
        mViewBinding.vsbMapRouteLineV3.let {
            it.max = max
            //定位中心显示最后一个经纬度
            it.progress = max
        }
    }

    /**
     * cSelectView 当前设置日期的view
     */
    private fun getHistoryDay(cSelectView: TypefaceTextView) {
        mViewBinding.apply {
//            mFromTimestamp = Utils.stringToTimestamp(
//                tvHomeRouteCalendarFromV3.text.toString(), Utils.DATE_FORMAT_PATTERN_EN13
//            )
//            mToTimestamp = Utils.stringToTimestamp(
//                tvHomeRouteCalendarToV3.text.toString(), Utils.DATE_FORMAT_PATTERN_EN13
//            )
            if (mToTimestamp - mFromTimestamp < 0) {
                checkCorrectDate(cSelectView)
            } else if (mToTimestamp - mFromTimestamp > mOnlySelectDay * 24 * 60 * 60 * 1000) {
                checkCorrectDate(cSelectView)
            }

            getHomeV2Activity()?.getPet()?.apply {
                initState()
                mDataDetailViewModel.getHistoryByDay(
                    getHomeV2Activity()!!, deviceId, mFromTimestamp / 1000, mToTimestamp / 1000
                )
            }
        }
    }

    /**
     * 检测符合的日期
     */
    private fun checkCorrectDate(cSelectView: TypefaceTextView) {
        mViewBinding.apply {
            if (cSelectView == tvHomeRouteCalendarFromV3) {
                mToTimestamp = Utils.getAfterHowTimestamp(mFromTimestamp, mOnlySelectDay)
                if (mToTimestamp > mCurrentTimestamp) {
                    mToTimestamp = mCurrentTimestamp
                }
                tvHomeRouteCalendarToV3.text = Utils.formatTime(
                    mToTimestamp, Utils.DATE_FORMAT_PATTERN_EN13
                )
                mToCalenderDialog?.setSelectDate(mToTimestamp)
            } else {
                //结束日期小于开始日期，就默认选择结束日期前一天
                mFromTimestamp =
                    if (mFromTimestamp > mToTimestamp) Utils.getBeforeHowTimestamp(mToTimestamp, 1L)
                    else Utils.getBeforeHowTimestamp(mToTimestamp, mOnlySelectDay)
                tvHomeRouteCalendarFromV3.text = Utils.formatTime(
                    mFromTimestamp, Utils.DATE_FORMAT_PATTERN_EN13
                )
                mFromCalenderDialog?.setSelectDate(mFromTimestamp)
            }
        }
    }

    override fun onClick(v: View?) {
        mViewBinding.apply {
            when (v!!) {
                ilHomeRoutePetHeadV3.homeDataPetNameSmall, ilHomeRoutePetHeadV3.homeDataPetHeadSmall.root -> {
                    getHomeV2Activity()?.let {
                        if (!it.isNotifyRefreshLocation) it.selectPetDialog(false)
                    }
                }

                llHomeRouteCalendarFromV3 -> {
                    getHomeV2Activity()?.getPet()?.let {
                        //防止执行多次弹窗
                        if (isLimitClick()) {
                            return
                        }
                        if (Util.checkPackageLimit(getHomeV2Activity()!!, it.deviceId)) {
                            mRechargeBackType = it.availableOrder
                            return
                        }
                    }

                    if (null == mFromCalenderDialog) {
                        mFromCalenderDialog = ShowCalenderAndTimeDialog(
                            mContext!!,
                            tvHomeRouteCalendarFromV3,
                            object : BaseDialog.OnDialogSelectListener {
                                override fun onSelectClick(dialog: BaseDialog<*>, any: Any) {
                                    mCurrentTimestamp = System.currentTimeMillis()
                                    isSelectCustomDate = true
                                    mFromTimestamp = any as Long
                                    getHistoryDay(tvHomeRouteCalendarFromV3)
                                }
                            },
                            calenderShowTimestamp = mFromTimestamp,
                            format = Utils.DATE_FORMAT_PATTERN_EN13,
                            minLastDayRange = 29
                        )
                    }
                    mFromCalenderDialog?.show()
                }

                llHomeRouteCalendarToV3 -> {
                    getHomeV2Activity()?.getPet()?.let {
                        //防止执行多次弹窗
                        if (isLimitClick()) {
                            return
                        }
                        if (Util.checkPackageLimit(getHomeV2Activity()!!, it.deviceId)) {
                            mRechargeBackType = it.availableOrder
                            return
                        }
                    }
                    if (null == mToCalenderDialog) {
                        mToCalenderDialog = ShowCalenderAndTimeDialog(
                            mContext!!,
                            tvHomeRouteCalendarToV3,
                            object : BaseDialog.OnDialogSelectListener {
                                override fun onSelectClick(dialog: BaseDialog<*>, any: Any) {
                                    isSelectCustomDate = true
                                    mToTimestamp = any as Long
                                    getHistoryDay(tvHomeRouteCalendarToV3)
                                }
                            },
                            calenderShowTimestamp = mToTimestamp,
                            format = Utils.DATE_FORMAT_PATTERN_EN13,
                            minLastDayRange = 29
                        )
                    }
                    mToCalenderDialog?.show()
                }

                ivHomeRouteMapTypeBtnV3 -> mHistoryDataMapCommon.switchSatelliteAndNormalMapType()
                ivMapRouteLineV3LastBtn -> {
                    if (vsbMapRouteLineV3.progress == 0) {
                        return
                    }
                    vsbMapRouteLineV3.progress -= 1
                    mHistoryDataMapCommon.slideStopChanged(vsbMapRouteLineV3.progress)
                }

                ivMapRouteLineV3NextBtn -> {
                    if (vsbMapRouteLineV3.progress == vsbMapRouteLineV3.max) {
                        return
                    }
                    vsbMapRouteLineV3.progress += 1
                    mHistoryDataMapCommon.slideStopChanged(vsbMapRouteLineV3.progress)
                }
            }
        }
    }
}