Home > Blockchain >  When I tap too quickly, Two or more same DialogFragment pop up. However this is happening in only An
When I tap too quickly, Two or more same DialogFragment pop up. However this is happening in only An

Time:12-28

Right now, I am calling this function before calling the fragment

fun toggleUIEventsListener(delay: Long = 1000) {
    activity?.window?.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE)
    Timer().schedule(delay) {
        activity?.runOnUiThread {
            activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE)
        }
    }
}

CodePudding user response:

I am sure it will happen in a real device as well. Check in other phones and try tapping as fast as you can (twice) and you will realise that its happening in some real devices as well.

The way you can fix this is... make a boolean say, isClicked, set it to true when its been clicked and then do not allow user to click it for atleast 3 seconds, after that the user should again be able to click that button.

  • Related