Android FragmentManager Listeners
<p>While searching for the best way to store and notify listeners (weak references vs strong references, anonymous listeners vs garbage collector), I took a look at how Google implement their listeners. The following code codes from the FragmentManager class:</p>

<pre><code>ArrayList&lt;OnBackStackChangedListener&gt; mBackStackChangeListeners;

public void removeOnBackStackChangedListener(OnBackStackChangedListener listener) {
    if (mBackStackChangeListeners != null) {
        mBackStackChangeListeners.remove(listener);
    }
}

void reportBackStackChanged() {
    if (mBackStackChangeListeners != null) {
        for (int i=0; i&lt;mBackStackChangeListeners.size(); i++) {
           mBackStackChangeListeners.get(i).onBackStackChanged();
        }
    }
}
</code></pre>

<p>If there is a listener removed in its <code>onBackStackChanged</code>, something like:</p>

<pre><code>@Override
void onBackStackChanged()
{
    mFragmentManager.removeOnBackStackChangedListener(this);
}
</code></pre>

<p>It seems to me that the next listener in the ArrayList will be skipped. </p>

<p>Am I missing something? Is this something that is not supposed to be done?</p>
