Avoid your click view from double click which will produce a bug.
maven { url 'https://jitpack.io' }implementation 'com.github.eriffanani:PreventDoubleClick:1.0.0'- Java
new PreventDoubleClick(() -> {
// TODO ACTION
});- Kotlin
PreventDoubleClick {
// TODO ACTION
}- Normal Button
- Prevent Double Click
The button can be re-clicked after the specified interval is completed. The default interval is 600 milliseconds.
- Java
long interval = 1000L; // 1 seconds
new PreventDoubleClick(interval, () -> {
// TODO ACTION
});- Kotlin
val interval = 1000L // 1 seconds
PreventDoubleClick(interval) {
// TODO ACTION
}- Java Function
public void onClickMyButton() {
new PreventDoubleClick(() -> {
// TODO ACTION
});
}- Java View Click Listener
myButton.setOnClickListener(view -> {
new PreventDoubleClick(() -> {
// TODO ACTION
});
});- Kotlin Function
fun onClickMyButton() {
PreventDoubleClick {
// TODO ACTION
}
}- Kotlin View Click Listener
myButton.setOnClickListener {
PreventDoubleClick {
// TODO ACTION
}
}Copyright 2022 Mukhammad Erif Fanani
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

