pgreze / android-reactions

Facebook like reaction picker for Android
Apache License 2.0
158 stars 46 forks source link

Popup reaction with long click #21

Open sopharasum opened 3 years ago

sopharasum commented 3 years ago

Does this library possible to implement with long click ?

pgreze commented 3 years ago

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

sopharasum commented 3 years ago

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 ?

pgreze commented 3 years ago

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 👍

SanushRadalage commented 2 years ago

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!

yongjhih commented 1 year ago
    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" }
    }