|
|
|
@ -6,21 +6,21 @@ import android.view.MotionEvent
@@ -6,21 +6,21 @@ import android.view.MotionEvent
|
|
|
|
|
import android.widget.FrameLayout |
|
|
|
|
|
|
|
|
|
class DisableableFrameLayout : FrameLayout { |
|
|
|
|
interface Callback { |
|
|
|
|
fun shouldRegisterTouch(): Boolean |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var callback: Callback? = null |
|
|
|
|
var callback: ((MotionEvent?) -> Boolean)? = null |
|
|
|
|
|
|
|
|
|
constructor(context: Context) : super(context) |
|
|
|
|
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) |
|
|
|
|
constructor(context: Context, attrs: AttributeSet?, style: Int) : super(context, attrs, style) |
|
|
|
|
|
|
|
|
|
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean { |
|
|
|
|
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean { |
|
|
|
|
callback?.let { |
|
|
|
|
return !it.shouldRegisterTouch() |
|
|
|
|
return !it(event) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun setShouldRegisterTouch(callback: (event: MotionEvent?) -> Boolean) { |
|
|
|
|
this.callback = callback |
|
|
|
|
} |
|
|
|
|
} |