1 package com.airbnb.lottie.samples.views 2 3 import android.content.Context 4 import androidx.customview.widget.ViewDragHelper 5 import android.util.AttributeSet 6 import android.view.MotionEvent 7 import android.widget.FrameLayout 8 9 class InterceptingFrameLayout @JvmOverloads constructor( 10 context: Context, 11 attrs: AttributeSet? = null, 12 defStyleAttr: Int = 0 13 ) : FrameLayout(context, attrs, defStyleAttr) { 14 15 var viewDragHelper: ViewDragHelper? = null 16 onInterceptTouchEventnull17 override fun onInterceptTouchEvent(ev: MotionEvent): Boolean { 18 if (viewDragHelper?.shouldInterceptTouchEvent(ev) == true) return true 19 return super.onInterceptTouchEvent(ev) 20 } 21 onTouchEventnull22 override fun onTouchEvent(event: MotionEvent): Boolean { 23 viewDragHelper?.processTouchEvent(event) 24 return true 25 } 26 }