Context of the Problem
I was currently trying to build a functionality to fast forward videos in ExoPlayer exactly like how Youtube does it. I thought that I could add a double click listener and I was able to do that using the answer given here.
Problem
The problem I am facing is that I was getting the ripple animation even when I do a single click which is not what I want. I want to be able to get a ripple only when a double click is triggered. So, for this, I tried to get the number of clicks and then accordingly set the ripple visibility on the view but it did not seem to work for me and instead giving a weird behaviour. The issue can be seen in the gif given below* :

It can be clearly seen that on single click, it shows ripple. On double click, it shows one ripple right but the other one comes out from nowhere!
Code
Kotlin
var doubleClickLastTime = 0L var clicksDone = 0 binding.forward.setOnClickListener { if((System.currentTimeMillis() - doubleClickLastTimeF) < 350){ doubleClickLastTime = 0 clicksDone = 0 exoPlayer.seekTo(exoPlayer.contentPosition + 10000) }else{ if (clicksDoneF == 0){ binding.forward.foreground = null }else{ binding.forward.foreground = with(TypedValue()) { this@VideoPlayer.theme.resolveAttribute( android.R.attr.selectableItemBackground, this, true) ContextCompat.getDrawable(this@VideoPlayerFromUrl, resourceId) } } clicksDone++ doubleClickLastTime = System.currentTimeMillis() } }
XML
<androidx.cardview.widget.CardView android:id="@+id/forward" android:layout_width="550dp" android:layout_height="match_parent" app:layout_constraintStart_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_marginVertical="50dp" android:foreground="?selectableItemBackgroundBorderless" app:cardCornerRadius="16px" app:cardElevation="0dp" android:backgroundTint="@android:color/transparent"/>
*Sorry for the bad gif quality