When developing Android apps, one often wants to prevent a user from accidentally clicking the same button twice. Otherwise it might happen that two equal activities/fragments are launched (or some other stuff runs twice).
There exist multiple solutions for this issue. For example: maintaining a "last clicked time stamp", disabling views, subclassing buttons...
However, none of these solutions is good. Either it clutters up the activities with boilerplate code, or it is too specific to only one type of view.
I seek a generic solution that satisfies the following requirements:
(R1) The double click prevention should require at most one additional line of code.
(R2) The double click prevention should be applicable to many different types of views (e.g. Button, MaterialButton,...).
EDIT: I found the activity-based solutions too cluttered. Therefore I wrote a listener-based solution for onClick and onItemClick: https://github.com/fkirc/throttle-click-listener