package com.gh.gamecenter.common.view

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.ScrollView

/**
 * 不能滑动的 ScrollView
 */
class FixedScrollView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
    ScrollView(context, attrs) {

    override fun onTouchEvent(ev: MotionEvent?): Boolean {
        // super.onTouchEvent may cause IllegalArgumentException which is crazy!
        try {
            return when (ev?.action) {
                MotionEvent.ACTION_DOWN -> true
                else -> super.onTouchEvent(ev)
            }
        } catch (e: IllegalArgumentException) {
            e.printStackTrace()
        }
        return false
    }

    override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
        return true
    }

}