android-reactions
android-reactions copied to clipboard
Popup reaction with long click
Does this library possible to implement with long click ?
No, it's not possible for now. It was started in #11 but it hasn't moved the POC step yet 😕
No, it's not possible for now. It was started in #11 but it hasn't moved the POC step yet confused
I've got your point. However, are you planning to think over the issue #15 ?
I definitely realize that this library is still lacking customization options and/or extensibility, especially regarding animations. But at the same time, I moved from actively implementing this library as the main user to just give this work back to the community. So I'm definitely open for contributions but not planning to add myself huge features that I cannot judge with confidence, considering I'm not anymore an active user of this library.
In a few words, if you want new features, please push a first POC showing your need and if it's good enough to be merged like #22 let's do it, but if it's breaking some core parts like #11 we can work together on how solve blockers 👍
yourButton.setOnTouchListener(View.OnTouchListener { arg0, arg1 -> when (arg1.action) { MotionEvent.ACTION_DOWN -> { timer = Timer() timer.schedule(object : TimerTask() { override fun run() { CoroutineScope(Dispatchers.Main).launch { popup.onTouch(arg0, arg1) } } }, 500) //time out 1/2s return@OnTouchListener true } MotionEvent.ACTION_UP -> { timer.cancel() return@OnTouchListener true } else -> false } })
This is work for me!
var longPressed = false
setOnTouchListener { v, event ->
var touched = false
if (longPressed) {
touched = popup.onTouch(v, event)
}
if (event.action == MotionEvent.ACTION_UP) {
longPressed = false
touched = false
}
return@setOnTouchListener touched
}
setOnLongClickListener {
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
it.context.toastShort { "LongPressed" }
longPressed = true
false
}
setOnClickListener {
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
it.context.toastShort { "Clicked" }
}