mirror of
https://github.com/apognu/otter
synced 2025-02-18 19:50:35 +01:00
Cleaned up DisableableFrameLayout.
This commit is contained in:
parent
1e62cc1f4e
commit
85e9f14e2a
@ -78,15 +78,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
|
||||||
(container as? DisableableFrameLayout)?.callback = object : DisableableFrameLayout.Callback {
|
(container as? DisableableFrameLayout)?.setShouldRegisterTouch { _ ->
|
||||||
override fun shouldRegisterTouch(): Boolean {
|
if (now_playing.isOpened()) {
|
||||||
if (now_playing.isOpened()) {
|
now_playing.close()
|
||||||
now_playing.close()
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
return@setShouldRegisterTouch false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
favoritedRepository.update(this, lifecycleScope)
|
favoritedRepository.update(this, lifecycleScope)
|
||||||
|
@ -6,21 +6,21 @@ import android.view.MotionEvent
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
|
|
||||||
class DisableableFrameLayout : FrameLayout {
|
class DisableableFrameLayout : FrameLayout {
|
||||||
interface Callback {
|
var callback: ((MotionEvent?) -> Boolean)? = null
|
||||||
fun shouldRegisterTouch(): Boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
var callback: Callback? = null
|
|
||||||
|
|
||||||
constructor(context: Context) : super(context)
|
constructor(context: Context) : super(context)
|
||||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||||
constructor(context: Context, attrs: AttributeSet?, style: Int) : super(context, attrs, style)
|
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 {
|
callback?.let {
|
||||||
return !it.shouldRegisterTouch()
|
return !it(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setShouldRegisterTouch(callback: (event: MotionEvent?) -> Boolean) {
|
||||||
|
this.callback = callback
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user