package cn.yyxx.eyuangame.core.ui

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.viewpager.widget.ViewPager

/**
 * @author #Suyghur.
 * Created on 2021/06/18
 */
class NoScrollViewPager : ViewPager {

    var scrollEnable: Boolean = true

    constructor(context: Context) : this(context, null)

    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)


    override fun onTouchEvent(ev: MotionEvent?): Boolean {
        return this.scrollEnable && super.onTouchEvent(ev)
    }

    override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
        return this.scrollEnable && super.onInterceptTouchEvent(ev)
    }

}