Hello. I implement on Android the project for this tutorial: Tutor on OneFingerZoom . The Observer design pattern is Observer . At a certain moment of the application operation (the thread has run its own, set a flag), it is required to remove the tracking of user’s touches on the device screen, more precisely, the Observable object state changes (changes its state based on the user's touch coordinates on the screen, then signals changes).

How is the tracking of this event removed? A certain method at successor View.OnTouchListener , a class implementing Observer or a class implementing Observable ?

  • Usually, in the implementation of an inherent collection of some kind, which contains a list of listeners, it is necessary to somehow remove it from there =) - Gorets

1 answer 1

From SDK by Observable :

deleteObserver(Observer observer)

Removes the specified observer from the list of observers.

Accordingly, in your code from some object that implements Observable , you must remove the subscription for a specific Observer . More precisely (without seeing the code) is difficult to say.

  • Yes. It works. So he acted. I just found logical jambs in my code a bit later. Nevertheless thank you. - zugzug 2:26