I basically have this function that validates the click of the user:
this.btnTryAgain.setOnClickListener {
viewModel.responsePictures.observeForever {
manageResponse(it)
}
clickcount += 1
if (clickcount == 3) {
findNavController().navigate(R.id.errorComprovante)
}
}
The observer is responsible for managing the response of the service. So if the users clicks the button 3 times and it doesn't get any success response, it goes to the errorComprovante. The problem is that if i use this code with the observer, it simply doesn't work.
Is there a way i can store the number of clicks so that it doesn't get lost? Thanks