Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server.wm; |
| 18 | |
| 19 | import static com.android.server.wm.AppTransition.DEFAULT_APP_TRANSITION_DURATION; |
| 20 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM; |
| 21 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
| 22 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
| 23 | |
| 24 | import android.animation.Animator; |
| 25 | import android.animation.ValueAnimator; |
Winson Chung | baa7b72 | 2017-03-03 21:33:44 -0800 | [diff] [blame^] | 26 | import android.content.Context; |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 27 | import android.graphics.Rect; |
Wale Ogunwale | 2ba7129 | 2016-05-05 09:16:47 -0700 | [diff] [blame] | 28 | import android.os.Handler; |
Robert Carr | f9aa2a9 | 2016-04-26 14:22:19 -0700 | [diff] [blame] | 29 | import android.os.IBinder; |
Wale Ogunwale | 5658e4b | 2016-02-12 12:22:19 -0800 | [diff] [blame] | 30 | import android.os.Debug; |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 31 | import android.util.ArrayMap; |
| 32 | import android.util.Slog; |
Winson Chung | baa7b72 | 2017-03-03 21:33:44 -0800 | [diff] [blame^] | 33 | import android.view.animation.AnimationUtils; |
| 34 | import android.view.animation.Interpolator; |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 35 | import android.view.animation.LinearInterpolator; |
Robert Carr | f9aa2a9 | 2016-04-26 14:22:19 -0700 | [diff] [blame] | 36 | import android.view.WindowManagerInternal; |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 37 | |
| 38 | /** |
| 39 | * Enables animating bounds of objects. |
| 40 | * |
| 41 | * In multi-window world bounds of both stack and tasks can change. When we need these bounds to |
| 42 | * change smoothly and not require the app to relaunch (e.g. because it handles resizes and |
| 43 | * relaunching it would cause poorer experience), these class provides a way to directly animate |
| 44 | * the bounds of the resized object. |
| 45 | * |
| 46 | * The object that is resized needs to implement {@link AnimateBoundsUser} interface. |
Wale Ogunwale | 2ba7129 | 2016-05-05 09:16:47 -0700 | [diff] [blame] | 47 | * |
| 48 | * NOTE: All calls to methods in this class should be done on the UI thread |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 49 | */ |
| 50 | public class BoundsAnimationController { |
Wale Ogunwale | 5658e4b | 2016-02-12 12:22:19 -0800 | [diff] [blame] | 51 | private static final boolean DEBUG_LOCAL = false; |
| 52 | private static final boolean DEBUG = DEBUG_LOCAL || DEBUG_ANIM; |
| 53 | private static final String TAG = TAG_WITH_CLASS_NAME || DEBUG_LOCAL |
| 54 | ? "BoundsAnimationController" : TAG_WM; |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 55 | private static final int DEBUG_ANIMATION_SLOW_DOWN_FACTOR = 1; |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 56 | |
Winson Chung | baa7b72 | 2017-03-03 21:33:44 -0800 | [diff] [blame^] | 57 | private static final int DEFAULT_TRANSITION_DURATION = 425; |
| 58 | |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 59 | // Only accessed on UI thread. |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 60 | private ArrayMap<AnimateBoundsUser, BoundsAnimator> mRunningAnimations = new ArrayMap<>(); |
| 61 | |
Wale Ogunwale | 2ba7129 | 2016-05-05 09:16:47 -0700 | [diff] [blame] | 62 | private final class AppTransitionNotifier |
| 63 | extends WindowManagerInternal.AppTransitionListener implements Runnable { |
Robert Carr | f9aa2a9 | 2016-04-26 14:22:19 -0700 | [diff] [blame] | 64 | |
Wale Ogunwale | 2ba7129 | 2016-05-05 09:16:47 -0700 | [diff] [blame] | 65 | public void onAppTransitionCancelledLocked() { |
| 66 | animationFinished(); |
| 67 | } |
| 68 | public void onAppTransitionFinishedLocked(IBinder token) { |
| 69 | animationFinished(); |
| 70 | } |
| 71 | private void animationFinished() { |
| 72 | if (mFinishAnimationAfterTransition) { |
| 73 | mHandler.removeCallbacks(this); |
| 74 | // This might end up calling into activity manager which will be bad since we have the |
| 75 | // window manager lock held at this point. Post a message to take care of the processing |
| 76 | // so we don't deadlock. |
| 77 | mHandler.post(this); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public void run() { |
| 83 | for (int i = 0; i < mRunningAnimations.size(); i++) { |
| 84 | final BoundsAnimator b = mRunningAnimations.valueAt(i); |
| 85 | b.onAnimationEnd(null); |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | private final Handler mHandler; |
Robert Carr | f9aa2a9 | 2016-04-26 14:22:19 -0700 | [diff] [blame] | 91 | private final AppTransition mAppTransition; |
Wale Ogunwale | 2ba7129 | 2016-05-05 09:16:47 -0700 | [diff] [blame] | 92 | private final AppTransitionNotifier mAppTransitionNotifier = new AppTransitionNotifier(); |
Winson Chung | baa7b72 | 2017-03-03 21:33:44 -0800 | [diff] [blame^] | 93 | private final Interpolator mFastOutSlowInInterpolator; |
Robert Carr | f9aa2a9 | 2016-04-26 14:22:19 -0700 | [diff] [blame] | 94 | private boolean mFinishAnimationAfterTransition = false; |
| 95 | |
Winson Chung | baa7b72 | 2017-03-03 21:33:44 -0800 | [diff] [blame^] | 96 | BoundsAnimationController(Context context, AppTransition transition, Handler handler) { |
Wale Ogunwale | 2ba7129 | 2016-05-05 09:16:47 -0700 | [diff] [blame] | 97 | mHandler = handler; |
Robert Carr | f9aa2a9 | 2016-04-26 14:22:19 -0700 | [diff] [blame] | 98 | mAppTransition = transition; |
| 99 | mAppTransition.registerListenerLocked(mAppTransitionNotifier); |
Winson Chung | baa7b72 | 2017-03-03 21:33:44 -0800 | [diff] [blame^] | 100 | mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, |
| 101 | com.android.internal.R.interpolator.fast_out_slow_in); |
Robert Carr | f9aa2a9 | 2016-04-26 14:22:19 -0700 | [diff] [blame] | 102 | } |
| 103 | |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 104 | private final class BoundsAnimator extends ValueAnimator |
| 105 | implements ValueAnimator.AnimatorUpdateListener, ValueAnimator.AnimatorListener { |
| 106 | private final AnimateBoundsUser mTarget; |
Winson Chung | 84a3834 | 2016-11-08 16:15:10 -0800 | [diff] [blame] | 107 | private final Rect mFrom = new Rect(); |
| 108 | private final Rect mTo = new Rect(); |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 109 | private final Rect mTmpRect = new Rect(); |
| 110 | private final Rect mTmpTaskBounds = new Rect(); |
Filip Gruszczynski | c17d8b7 | 2016-02-03 16:52:59 -0800 | [diff] [blame] | 111 | private final boolean mMoveToFullScreen; |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 112 | // True if this this animation was cancelled and will be replaced the another animation from |
| 113 | // the same {@link #AnimateBoundsUser} target. |
| 114 | private boolean mWillReplace; |
| 115 | // True to true if this animation replaced a previous animation of the same |
| 116 | // {@link #AnimateBoundsUser} target. |
| 117 | private final boolean mReplacement; |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 118 | |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 119 | // Depending on whether we are animating from |
| 120 | // a smaller to a larger size |
| 121 | private final int mFrozenTaskWidth; |
| 122 | private final int mFrozenTaskHeight; |
| 123 | |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 124 | BoundsAnimator(AnimateBoundsUser target, Rect from, Rect to, |
| 125 | boolean moveToFullScreen, boolean replacement) { |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 126 | super(); |
| 127 | mTarget = target; |
Winson Chung | 84a3834 | 2016-11-08 16:15:10 -0800 | [diff] [blame] | 128 | mFrom.set(from); |
| 129 | mTo.set(to); |
Filip Gruszczynski | c17d8b7 | 2016-02-03 16:52:59 -0800 | [diff] [blame] | 130 | mMoveToFullScreen = moveToFullScreen; |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 131 | mReplacement = replacement; |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 132 | addUpdateListener(this); |
| 133 | addListener(this); |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 134 | |
| 135 | // If we are animating from smaller to larger, we want to change the task bounds |
| 136 | // to their final size immediately so we can use scaling to make the window |
| 137 | // larger. Likewise if we are going from bigger to smaller, we want to wait until |
| 138 | // the end so we don't have to upscale from the smaller finished size. |
| 139 | if (animatingToLargerSize()) { |
| 140 | mFrozenTaskWidth = mTo.width(); |
| 141 | mFrozenTaskHeight = mTo.height(); |
| 142 | } else { |
| 143 | mFrozenTaskWidth = mFrom.width(); |
| 144 | mFrozenTaskHeight = mFrom.height(); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | boolean animatingToLargerSize() { |
| 149 | if (mFrom.width() * mFrom.height() > mTo.width() * mTo.height()) { |
| 150 | return false; |
| 151 | } |
| 152 | return true; |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | @Override |
| 156 | public void onAnimationUpdate(ValueAnimator animation) { |
| 157 | final float value = (Float) animation.getAnimatedValue(); |
| 158 | final float remains = 1 - value; |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 159 | mTmpRect.left = (int) (mFrom.left * remains + mTo.left * value + 0.5f); |
| 160 | mTmpRect.top = (int) (mFrom.top * remains + mTo.top * value + 0.5f); |
| 161 | mTmpRect.right = (int) (mFrom.right * remains + mTo.right * value + 0.5f); |
| 162 | mTmpRect.bottom = (int) (mFrom.bottom * remains + mTo.bottom * value + 0.5f); |
Wale Ogunwale | 5658e4b | 2016-02-12 12:22:19 -0800 | [diff] [blame] | 163 | if (DEBUG) Slog.d(TAG, "animateUpdate: mTarget=" + mTarget + " mBounds=" |
| 164 | + mTmpRect + " from=" + mFrom + " mTo=" + mTo + " value=" + value |
| 165 | + " remains=" + remains); |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 166 | |
Robert Carr | c729460 | 2016-05-13 11:32:05 -0700 | [diff] [blame] | 167 | mTmpTaskBounds.set(mTmpRect.left, mTmpRect.top, |
| 168 | mTmpRect.left + mFrozenTaskWidth, mTmpRect.top + mFrozenTaskHeight); |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 169 | |
Robert Carr | c729460 | 2016-05-13 11:32:05 -0700 | [diff] [blame] | 170 | if (!mTarget.setPinnedStackSize(mTmpRect, mTmpTaskBounds)) { |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 171 | // Whoops, the target doesn't feel like animating anymore. Let's immediately finish |
| 172 | // any further animation. |
| 173 | animation.cancel(); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | |
| 178 | @Override |
| 179 | public void onAnimationStart(Animator animation) { |
Wale Ogunwale | 5658e4b | 2016-02-12 12:22:19 -0800 | [diff] [blame] | 180 | if (DEBUG) Slog.d(TAG, "onAnimationStart: mTarget=" + mTarget |
| 181 | + " mReplacement=" + mReplacement); |
Robert Carr | f9aa2a9 | 2016-04-26 14:22:19 -0700 | [diff] [blame] | 182 | mFinishAnimationAfterTransition = false; |
Robert Carr | 69016e3 | 2016-04-18 11:52:21 -0700 | [diff] [blame] | 183 | // Ensure that we have prepared the target for animation before |
| 184 | // we trigger any size changes, so it can swap surfaces |
| 185 | // in to appropriate modes, or do as it wishes otherwise. |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 186 | if (!mReplacement) { |
Robert Carr | 7e4c90e | 2017-02-15 19:52:38 -0800 | [diff] [blame] | 187 | mTarget.onAnimationStart(mMoveToFullScreen); |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 188 | } |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 189 | |
Robert Carr | 69016e3 | 2016-04-18 11:52:21 -0700 | [diff] [blame] | 190 | // Immediately update the task bounds if they have to become larger, but preserve |
| 191 | // the starting position so we don't jump at the beginning of the animation. |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 192 | if (animatingToLargerSize()) { |
Robert Carr | 69016e3 | 2016-04-18 11:52:21 -0700 | [diff] [blame] | 193 | mTmpRect.set(mFrom.left, mFrom.top, |
| 194 | mFrom.left + mFrozenTaskWidth, mFrom.top + mFrozenTaskHeight); |
| 195 | mTarget.setPinnedStackSize(mFrom, mTmpRect); |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 196 | } |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | @Override |
| 200 | public void onAnimationEnd(Animator animation) { |
Wale Ogunwale | 5658e4b | 2016-02-12 12:22:19 -0800 | [diff] [blame] | 201 | if (DEBUG) Slog.d(TAG, "onAnimationEnd: mTarget=" + mTarget |
| 202 | + " mMoveToFullScreen=" + mMoveToFullScreen + " mWillReplace=" + mWillReplace); |
Jaewan Kim | b003364 | 2016-04-22 18:41:37 +0900 | [diff] [blame] | 203 | |
Robert Carr | f9aa2a9 | 2016-04-26 14:22:19 -0700 | [diff] [blame] | 204 | // There could be another animation running. For example in the |
| 205 | // move to fullscreen case, recents will also be closing while the |
| 206 | // previous task will be taking its place in the fullscreen stack. |
| 207 | // we have to ensure this is completed before we finish the animation |
| 208 | // and take our place in the fullscreen stack. |
| 209 | if (mAppTransition.isRunning() && !mFinishAnimationAfterTransition) { |
| 210 | mFinishAnimationAfterTransition = true; |
| 211 | return; |
| 212 | } |
| 213 | |
Robert Carr | c729460 | 2016-05-13 11:32:05 -0700 | [diff] [blame] | 214 | finishAnimation(); |
| 215 | |
| 216 | mTarget.setPinnedStackSize(mTo, null); |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 217 | if (mMoveToFullScreen && !mWillReplace) { |
Filip Gruszczynski | c17d8b7 | 2016-02-03 16:52:59 -0800 | [diff] [blame] | 218 | mTarget.moveToFullscreen(); |
| 219 | } |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | @Override |
| 223 | public void onAnimationCancel(Animator animation) { |
| 224 | finishAnimation(); |
| 225 | } |
| 226 | |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 227 | @Override |
| 228 | public void cancel() { |
| 229 | mWillReplace = true; |
Wale Ogunwale | 5658e4b | 2016-02-12 12:22:19 -0800 | [diff] [blame] | 230 | if (DEBUG) Slog.d(TAG, "cancel: willReplace mTarget=" + mTarget); |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 231 | super.cancel(); |
| 232 | } |
| 233 | |
Wale Ogunwale | 5658e4b | 2016-02-12 12:22:19 -0800 | [diff] [blame] | 234 | /** Returns true if the animation target is the same as the input bounds. */ |
| 235 | public boolean isAnimatingTo(Rect bounds) { |
| 236 | return mTo.equals(bounds); |
| 237 | } |
| 238 | |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 239 | private void finishAnimation() { |
Wale Ogunwale | 5658e4b | 2016-02-12 12:22:19 -0800 | [diff] [blame] | 240 | if (DEBUG) Slog.d(TAG, "finishAnimation: mTarget=" + mTarget |
| 241 | + " callers" + Debug.getCallers(2)); |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 242 | if (!mWillReplace) { |
| 243 | mTarget.onAnimationEnd(); |
| 244 | } |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 245 | removeListener(this); |
| 246 | removeUpdateListener(this); |
| 247 | mRunningAnimations.remove(mTarget); |
| 248 | } |
| 249 | |
| 250 | @Override |
| 251 | public void onAnimationRepeat(Animator animation) { |
| 252 | |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | public interface AnimateBoundsUser { |
| 257 | /** |
| 258 | * Asks the target to directly (without any intermediate steps, like scheduling animation) |
| 259 | * resize its bounds. |
| 260 | * |
| 261 | * @return Whether the target still wants to be animated and successfully finished the |
| 262 | * operation. If it returns false, the animation will immediately be cancelled. The target |
| 263 | * should return false when something abnormal happened, e.g. it was completely removed |
| 264 | * from the hierarchy and is not valid anymore. |
| 265 | */ |
| 266 | boolean setSize(Rect bounds); |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 267 | /** |
| 268 | * Behaves as setSize, but freezes the bounds of any tasks in the target at taskBounds, |
| 269 | * to allow for more flexibility during resizing. Only |
| 270 | * works for the pinned stack at the moment. |
| 271 | */ |
| 272 | boolean setPinnedStackSize(Rect bounds, Rect taskBounds); |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 273 | |
Robert Carr | 7e4c90e | 2017-02-15 19:52:38 -0800 | [diff] [blame] | 274 | void onAnimationStart(boolean toFullscreen); |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 275 | |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 276 | /** |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 277 | * Callback for the target to inform it that the animation has ended, so it can do some |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 278 | * necessary cleanup. |
| 279 | */ |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 280 | void onAnimationEnd(); |
Filip Gruszczynski | c17d8b7 | 2016-02-03 16:52:59 -0800 | [diff] [blame] | 281 | |
| 282 | void moveToFullscreen(); |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 283 | } |
| 284 | |
Winson Chung | 5589333 | 2017-02-17 17:13:10 -0800 | [diff] [blame] | 285 | void animateBounds(final AnimateBoundsUser target, Rect from, Rect to, int animationDuration, |
| 286 | boolean moveToFullscreen) { |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 287 | final BoundsAnimator existing = mRunningAnimations.get(target); |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 288 | final boolean replacing = existing != null; |
Wale Ogunwale | 5658e4b | 2016-02-12 12:22:19 -0800 | [diff] [blame] | 289 | |
| 290 | if (DEBUG) Slog.d(TAG, "animateBounds: target=" + target + " from=" + from + " to=" + to |
| 291 | + " moveToFullscreen=" + moveToFullscreen + " replacing=" + replacing); |
| 292 | |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 293 | if (replacing) { |
Wale Ogunwale | 5658e4b | 2016-02-12 12:22:19 -0800 | [diff] [blame] | 294 | if (existing.isAnimatingTo(to)) { |
| 295 | // Just les the current animation complete if it has the same destination as the |
| 296 | // one we are trying to start. |
| 297 | if (DEBUG) Slog.d(TAG, "animateBounds: same destination as existing=" + existing |
| 298 | + " ignoring..."); |
| 299 | return; |
| 300 | } |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 301 | existing.cancel(); |
| 302 | } |
Wale Ogunwale | ce14452 | 2016-02-05 22:51:01 -0800 | [diff] [blame] | 303 | final BoundsAnimator animator = |
| 304 | new BoundsAnimator(target, from, to, moveToFullscreen, replacing); |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 305 | mRunningAnimations.put(target, animator); |
| 306 | animator.setFloatValues(0f, 1f); |
Wale Ogunwale | e75a9ad | 2016-03-18 20:43:49 -0700 | [diff] [blame] | 307 | animator.setDuration((animationDuration != -1 ? animationDuration |
Winson Chung | baa7b72 | 2017-03-03 21:33:44 -0800 | [diff] [blame^] | 308 | : DEFAULT_TRANSITION_DURATION) * DEBUG_ANIMATION_SLOW_DOWN_FACTOR); |
| 309 | animator.setInterpolator(mFastOutSlowInInterpolator); |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 310 | animator.start(); |
| 311 | } |
| 312 | } |