mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 889621 - Allow multiple listeners in PropertyAnimators (r=sriram)
This commit is contained in:
parent
8abd157f25
commit
bd2be833a7
@ -1165,7 +1165,7 @@ abstract public class BrowserApp extends GeckoApp
|
||||
}
|
||||
|
||||
mMainLayoutAnimator = new PropertyAnimator(animationLength, sTabsInterpolator);
|
||||
mMainLayoutAnimator.setPropertyAnimationListener(this);
|
||||
mMainLayoutAnimator.addPropertyAnimationListener(this);
|
||||
|
||||
if (hasTabsSideBar()) {
|
||||
mMainLayoutAnimator.attach(mMainLayout,
|
||||
|
@ -1262,7 +1262,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
curveTranslation);
|
||||
}
|
||||
|
||||
contentAnimator.setPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
|
||||
contentAnimator.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
|
||||
@Override
|
||||
public void onPropertyAnimationStart() {
|
||||
}
|
||||
@ -1345,7 +1345,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
0);
|
||||
}
|
||||
|
||||
contentAnimator.setPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
|
||||
contentAnimator.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
|
||||
@Override
|
||||
public void onPropertyAnimationStart() {
|
||||
}
|
||||
@ -1469,7 +1469,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
mForwardAnim = new PropertyAnimator(mSwitchingTabs ? 10 : FORWARD_ANIMATION_DURATION);
|
||||
final int width = mForward.getWidth() / 2;
|
||||
|
||||
mForwardAnim.setPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
|
||||
mForwardAnim.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
|
||||
@Override
|
||||
public void onPropertyAnimationStart() {
|
||||
if (!enabled) {
|
||||
|
@ -297,7 +297,7 @@ public class TabsTray extends TwoWayView
|
||||
mCloseAnimationCount++;
|
||||
mPendingClosedTabs.add(view);
|
||||
|
||||
animator.setPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
|
||||
animator.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
|
||||
@Override
|
||||
public void onPropertyAnimationStart() { }
|
||||
@Override
|
||||
@ -333,7 +333,7 @@ public class TabsTray extends TwoWayView
|
||||
final int tabId = tab.id;
|
||||
final int originalSize = (isVertical ? view.getHeight() : view.getWidth());
|
||||
|
||||
animator.setPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
|
||||
animator.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
|
||||
@Override
|
||||
public void onPropertyAnimationStart() { }
|
||||
@Override
|
||||
@ -367,7 +367,7 @@ public class TabsTray extends TwoWayView
|
||||
animator.attach(view, Property.TRANSLATION_Y, 0);
|
||||
|
||||
|
||||
animator.setPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
|
||||
animator.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
|
||||
@Override
|
||||
public void onPropertyAnimationStart() { }
|
||||
@Override
|
||||
|
@ -49,7 +49,7 @@ public class PropertyAnimator implements Runnable {
|
||||
private long mDuration;
|
||||
private float mDurationReciprocal;
|
||||
private List<ElementHolder> mElementsList;
|
||||
private PropertyAnimationListener mListener;
|
||||
private List<PropertyAnimationListener> mListeners;
|
||||
private FramePoster mFramePoster;
|
||||
private boolean mUseHardwareLayer;
|
||||
|
||||
@ -64,6 +64,7 @@ public class PropertyAnimator implements Runnable {
|
||||
mElementsList = new ArrayList<ElementHolder>();
|
||||
mFramePoster = FramePoster.create(this);
|
||||
mUseHardwareLayer = true;
|
||||
mListeners = null;
|
||||
}
|
||||
|
||||
public void setUseHardwareLayer(boolean useHardwareLayer) {
|
||||
@ -81,8 +82,12 @@ public class PropertyAnimator implements Runnable {
|
||||
mElementsList.add(element);
|
||||
}
|
||||
|
||||
public void setPropertyAnimationListener(PropertyAnimationListener listener) {
|
||||
mListener = listener;
|
||||
public void addPropertyAnimationListener(PropertyAnimationListener listener) {
|
||||
if (mListeners == null) {
|
||||
mListeners = new ArrayList<PropertyAnimationListener>();
|
||||
}
|
||||
|
||||
mListeners.add(listener);
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
@ -146,8 +151,11 @@ public class PropertyAnimator implements Runnable {
|
||||
|
||||
mFramePoster.postFirstAnimationFrame();
|
||||
|
||||
if (mListener != null)
|
||||
mListener.onPropertyAnimationStart();
|
||||
if (mListeners != null) {
|
||||
for (PropertyAnimationListener listener : mListeners) {
|
||||
listener.onPropertyAnimationStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -173,10 +181,15 @@ public class PropertyAnimator implements Runnable {
|
||||
|
||||
mElementsList.clear();
|
||||
|
||||
if (mListener != null) {
|
||||
if (snapToEndPosition)
|
||||
mListener.onPropertyAnimationEnd();
|
||||
mListener = null;
|
||||
if (mListeners != null) {
|
||||
if (snapToEndPosition) {
|
||||
for (PropertyAnimationListener listener : mListeners) {
|
||||
listener.onPropertyAnimationEnd();
|
||||
}
|
||||
}
|
||||
|
||||
mListeners.clear();
|
||||
mListeners = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user