Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for multiple listeners in DefaultTimeBar.java #3406

Closed
hallyhaa opened this issue Oct 30, 2017 · 0 comments
Closed

Allow for multiple listeners in DefaultTimeBar.java #3406

hallyhaa opened this issue Oct 30, 2017 · 0 comments

Comments

@hallyhaa
Copy link

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);
  }
ojw28 added a commit that referenced this issue Nov 2, 2017
Issue: #3406

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174214296
@ojw28 ojw28 closed this as completed Nov 3, 2017
@google google locked and limited conversation to collaborators Mar 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants