android-reactions icon indicating copy to clipboard operation
android-reactions copied to clipboard

Popup reaction with long click

Open sopharasum opened this issue 3 years ago • 5 comments

Does this library possible to implement with long click ?

sopharasum avatar Nov 16 '20 08:11 sopharasum

No, it's not possible for now. It was started in #11 but it hasn't moved the POC step yet 😕

pgreze avatar Nov 18 '20 14:11 pgreze

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 ?

sopharasum avatar Nov 19 '20 06:11 sopharasum

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 👍

pgreze avatar Nov 20 '20 02:11 pgreze

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!

SanushRadalage avatar Jan 04 '22 05:01 SanushRadalage

    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" }
    }

yongjhih avatar Oct 21 '22 12:10 yongjhih