2021-07-12 10:14:26 +02:00
|
|
|
package audio.funkwhale.ffa.views
|
2020-07-12 18:55:52 +02:00
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.util.AttributeSet
|
|
|
|
import android.view.MotionEvent
|
|
|
|
import android.widget.FrameLayout
|
|
|
|
|
2021-06-26 13:36:32 +02:00
|
|
|
class DisableableFrameLayout : FrameLayout {
|
2020-07-12 19:05:51 +02:00
|
|
|
var callback: ((MotionEvent?) -> Boolean)? = null
|
2020-07-12 18:55:52 +02:00
|
|
|
|
|
|
|
constructor(context: Context) : super(context)
|
|
|
|
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
|
|
|
constructor(context: Context, attrs: AttributeSet?, style: Int) : super(context, attrs, style)
|
|
|
|
|
2020-07-12 19:05:51 +02:00
|
|
|
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
|
2020-07-12 18:55:52 +02:00
|
|
|
callback?.let {
|
2020-07-12 19:05:51 +02:00
|
|
|
return !it(event)
|
2020-07-12 18:55:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
2020-07-12 19:05:51 +02:00
|
|
|
|
|
|
|
fun setShouldRegisterTouch(callback: (event: MotionEvent?) -> Boolean) {
|
|
|
|
this.callback = callback
|
|
|
|
}
|
2021-06-26 13:36:32 +02:00
|
|
|
}
|