A common problem in android apps for me seems to be, that click events can be triggered multiple times, when they should not.
I am using Butterknife - consider the following example
@OnClick(R.id.button_foto_aufnehmen)
protected void takePicture() {
m_camera.takePicture();
}
with a camera app with some layout containing
<SurfaceView
android:id="@+id/surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
...
<ImageButton
android:id="@+id/button_foto_aufnehmen"
.../>
Now it should not be possible to click the button again, until at least after the onPictureTaken
callback has completed - or even later.
Another example would be
I really don't want to manually introduce a boolean flag every time this comes up. I'd think of something like an annotation that allows me to specify an event that resets a boolean which is generated automatically. Anything but boilerplate code please.
So what is the best practice here (particularly keeping in mind the usage of butter knife)?