Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java |
| index f80439e8f7a28d8b1490f9dd96599eed6d6c8846..91d94c09eff056e0940bd5619d2a895e15de48e9 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java |
| @@ -17,6 +17,7 @@ import android.view.MotionEvent; |
| import android.view.View; |
| import android.widget.FrameLayout; |
| +import org.chromium.base.ObserverList; |
| import org.chromium.chrome.R; |
| import org.chromium.chrome.browser.infobar.InfoBarContainer.InfoBarAnimationListener; |
| @@ -60,12 +61,11 @@ import java.util.ArrayList; |
| * |
| * TODO(newt): finalize animation timings and interpolators. |
| */ |
| -class InfoBarContainerLayout extends FrameLayout { |
| - |
| +public class InfoBarContainerLayout extends FrameLayout { |
|
David Trainor- moved to gerrit
2017/04/17 23:33:40
This is sad, but it's the only way I could get Ite
gone
2017/04/18 21:05:19
Should be fine. Constructor's still package prote
|
| /** |
| * An interface for items that can be added to an InfoBarContainerLayout. |
| */ |
| - interface Item { |
| + public interface Item { |
| /** |
| * Returns the View that represents this infobar. This should have no background or borders; |
| * a background and shadow will be added by a wrapper view. |
| @@ -95,6 +95,13 @@ class InfoBarContainerLayout extends FrameLayout { |
| * any other infobars already visible. |
| */ |
| boolean isLegalDisclosure(); |
| + |
| + /** |
| + * Returns the type of infobar, as best as can be determined at this time. See |
| + * components/infobars/core/infobar_delegate.h. |
| + */ |
| + @InfoBarIdentifier |
| + int getInfoBarIdentifier(); |
| } |
| /** |
| @@ -146,10 +153,17 @@ class InfoBarContainerLayout extends FrameLayout { |
| } |
| /** |
| - * Sets a listener to receive updates when each animation is complete. |
| + * Adds a listener to receive updates when each animation is complete. |
| + */ |
| + void addAnimationListener(InfoBarAnimationListener listener) { |
| + mAnimationListeners.addObserver(listener); |
| + } |
| + |
| + /** |
| + * Removes a listener that was receiving updates when each animation is complete. |
| */ |
| - void setAnimationListener(InfoBarAnimationListener listener) { |
| - mAnimationListener = listener; |
| + void removeAnimationListener(InfoBarAnimationListener listener) { |
| + mAnimationListeners.removeObserver(listener); |
| } |
| ///////////////////////////////////////// |
| @@ -184,8 +198,8 @@ class InfoBarContainerLayout extends FrameLayout { |
| public void onAnimationEnd(Animator animation) { |
| mAnimation = null; |
| InfoBarAnimation.this.onAnimationEnd(); |
| - if (mAnimationListener != null) { |
| - mAnimationListener.notifyAnimationFinished(getAnimationType()); |
| + for (InfoBarAnimationListener listener : mAnimationListeners) { |
| + listener.notifyAnimationFinished(getAnimationType()); |
| } |
| processPendingAnimations(); |
| } |
| @@ -686,7 +700,7 @@ class InfoBarContainerLayout extends FrameLayout { |
| /** The current animation, or null if no animation is happening currently. */ |
| private InfoBarAnimation mAnimation; |
| - private InfoBarAnimationListener mAnimationListener; |
| + private ObserverList<InfoBarAnimationListener> mAnimationListeners = new ObserverList<>(); |
|
gone
2017/04/18 21:05:19
private final
David Trainor- moved to gerrit
2017/04/25 05:01:05
Done.
|
| private FloatingBehavior mFloatingBehavior; |
| @@ -769,6 +783,13 @@ class InfoBarContainerLayout extends FrameLayout { |
| runAnimation(mInfoBarWrappers.isEmpty() |
| ? new FirstInfoBarAppearingAnimation(itemToShow) |
| : new BackInfoBarAppearingAnimation(itemToShow)); |
| + return; |
| + } |
| + |
| + // Fifth, now that we've stabilized, let listeners know that we have no more animations. |
| + Item frontItem = mInfoBarWrappers.size() > 0 ? mInfoBarWrappers.get(0).getItem() : null; |
| + for (InfoBarAnimationListener listener : mAnimationListeners) { |
| + listener.notifyAllAnimationsFinished(frontItem); |
| } |
| } |