Avoid button multiple rapid clicks

前端 未结 20 1492
猫巷女王i
猫巷女王i 2020-11-28 02:55

I have a problem with my app that if the user clicks the button multiple times quickly, then multiple events are generated before even my dialog holding the button disappear

20条回答
  •  盖世英雄少女心
    2020-11-28 03:17

    With RxBinding it can be done easily. Here is an example:

    RxView.clicks(view).throttleFirst(500, TimeUnit.MILLISECONDS).subscribe(empty -> {
                // action on click
            });
    

    Add the following line in build.gradle to add RxBinding dependency:

    compile 'com.jakewharton.rxbinding:rxbinding:0.3.0'
    

提交回复
热议问题