Похожие чаты

I have a function that gets triggered on MotionEvent.ACTION_MOVE, Is

there a way I can limit the function so it can be called only say, 1 time in 50ms ?

1 ответов

11 просмотров

There are 2 techniques for limiting function calling rate: debouncing and throttling. Unfortunately there is no easy and straightforward way to implement such functionality in Java. You may want to take a look at this library https://github.com/ThomasGirard/JDebounce or RateLimiter class from Guava. (Javascript guys are laughing at us because they have _.throttle and _.debounce 😄)

Похожие вопросы

Карта сайта