Skip to content

Allow for multiple listeners in DefaultTimeBar.java #3406

Closed
@hallyhaa

Description

Issue description

DefaultTimeBar has a setListener method, but no addListener. It is impossible to add listeners without overwriting the default listener behaviour. It would be very nice to be able to just add one more listener to have one's own logic executed in addition to the default.

I believe the only changes needed in the code, are something like

    private List<OnScrubListener> listeners = new ArrayList<OnScrubListener>();

    public boolean addListener(OnScrubListener listener) {
        return listeners.add(listener);
    }

    public boolean removeListener(OnScrubListener listener) {
        return listeners.remove(listener);
    }

... and then on each use of the listener, where today the code simply checks for null, one could replace the if-null-check with a for-loop, thus (example taken from onTouchEvent():

  for (OnScrubListener listener : listeners) {
    listener.onScrubMove(this, scrubPosition);
  }

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions