plaid icon indicating copy to clipboard operation
plaid copied to clipboard

Double tap on list cause shared element transition bug.

Open Gurupreet opened this issue 5 years ago • 5 comments

I added shared element transition from list element to my activity on an imageview but I had to remove it from our production app because of this behavior. Whenever you double tap on list item and it opens two activity closing both doesn't bring back the Image in list view.

Gurupreet avatar Nov 17 '18 11:11 Gurupreet

This happens in a lot of apps because there's rarely a debounce for clicks.

👍 It's more noticeable here because of the animation and the aberrant behaviour when dismissing both activities.

Thanks for reporting!

ataulm avatar Nov 17 '18 12:11 ataulm

Any workaround or solution regarding this?

Gurupreet avatar Nov 19 '18 06:11 Gurupreet

I've seen an abstract implementation of View.OnClickListener which is used instead of an anonymous one. This implementation keeps track of when the last click occurred and swallows further events unless the delta between the clicks is beyond some threshold.

Instead of a time based delta, you could try a lifecycle observer (attached to the source activity) which resets the click listener onResume.

You could try this (I haven't 😬):

fun View.setNavigationClickListener(onClick: (View?) -> Unit) {
    setOnClickListener(NavigationClickListener(onClick))
}
class NavigationClickListener(private val doOnClick: (View?) -> Unit) : View.OnClickListener, LifecycleObserver {

    override fun onClick(v: View?) {
        if (clickable) {
            doOnClick(v)
            clickable = false
        }
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
    fun reset() {
        clickable = true
    }

    companion object {
        private var clickable = true
    }
}

ataulm avatar Nov 19 '18 07:11 ataulm

Hello Everyone,

I tried your solution but no luck. In my case, this issue occurs only on iBall Devices and when i see logs it says cleans up scroll view and hardware accelerator

chandankumar2517 avatar Aug 08 '19 08:08 chandankumar2517

please suggest.

chandankumar2517 avatar Aug 08 '19 08:08 chandankumar2517