| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.infobar; | 5 package org.chromium.chrome.browser.infobar; |
| 6 | 6 |
| 7 import android.animation.Animator; | 7 import android.animation.Animator; |
| 8 import android.animation.AnimatorListenerAdapter; | 8 import android.animation.AnimatorListenerAdapter; |
| 9 import android.animation.AnimatorSet; | 9 import android.animation.AnimatorSet; |
| 10 import android.animation.ObjectAnimator; | 10 import android.animation.ObjectAnimator; |
| 11 import android.animation.PropertyValuesHolder; | 11 import android.animation.PropertyValuesHolder; |
| 12 import android.annotation.TargetApi; | 12 import android.annotation.TargetApi; |
| 13 import android.os.Build; | 13 import android.os.Build; |
| 14 import android.view.View; | 14 import android.view.View; |
| 15 import android.view.ViewTreeObserver; | 15 import android.view.ViewTreeObserver; |
| 16 import android.view.animation.AccelerateDecelerateInterpolator; | 16 import android.view.animation.AccelerateDecelerateInterpolator; |
| 17 import android.widget.LinearLayout; | 17 import android.widget.LinearLayout; |
| 18 import android.widget.TextView; | 18 import android.widget.TextView; |
| 19 | 19 |
| 20 import org.chromium.base.ApiCompatibilityUtils; | |
| 21 import org.chromium.chrome.R; | 20 import org.chromium.chrome.R; |
| 22 | 21 |
| 23 import java.util.ArrayList; | 22 import java.util.ArrayList; |
| 24 | 23 |
| 25 /** | 24 /** |
| 26 * Sets up animations to move InfoBars around inside of the InfoBarContainer. | 25 * Sets up animations to move InfoBars around inside of the InfoBarContainer. |
| 27 * | 26 * |
| 28 * Animations proceed in several phases: | 27 * Animations proceed in several phases: |
| 29 * 1) Prep work is done for the InfoBar so that the View being animated in (if i
t exists) is | 28 * 1) Prep work is done for the InfoBar so that the View being animated in (if i
t exists) is |
| 30 * properly sized. This involves adding the View to a FrameLayout with a vis
ibility of | 29 * properly sized. This involves adding the View to a FrameLayout with a vis
ibility of |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 */ | 114 */ |
| 116 public int getAnimationType() { | 115 public int getAnimationType() { |
| 117 return mAnimationType; | 116 return mAnimationType; |
| 118 } | 117 } |
| 119 | 118 |
| 120 /** | 119 /** |
| 121 * Catch when the layout occurs, which lets us know when the View has been s
ized properly. | 120 * Catch when the layout occurs, which lets us know when the View has been s
ized properly. |
| 122 */ | 121 */ |
| 123 @Override | 122 @Override |
| 124 public void onGlobalLayout() { | 123 public void onGlobalLayout() { |
| 125 ApiCompatibilityUtils.removeOnGlobalLayoutListener(mTargetWrapperView, t
his); | 124 mTargetWrapperView.getViewTreeObserver().removeOnGlobalLayoutListener(th
is); |
| 126 continueAnimation(); | 125 continueAnimation(); |
| 127 } | 126 } |
| 128 | 127 |
| 129 private void continueAnimation() { | 128 private void continueAnimation() { |
| 130 if (mAnimationStarted) return; | 129 if (mAnimationStarted) return; |
| 131 mAnimationStarted = true; | 130 mAnimationStarted = true; |
| 132 | 131 |
| 133 int indexOfWrapperView = mLinearLayout.indexOfChild(mTargetWrapperView); | 132 int indexOfWrapperView = mLinearLayout.indexOfChild(mTargetWrapperView); |
| 134 assert indexOfWrapperView != -1; | 133 assert indexOfWrapperView != -1; |
| 135 | 134 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } | 233 } |
| 235 } | 234 } |
| 236 }); | 235 }); |
| 237 | 236 |
| 238 mAnimatorSet.playTogether(animators); | 237 mAnimatorSet.playTogether(animators); |
| 239 mAnimatorSet.setDuration(ANIMATION_DURATION_MS); | 238 mAnimatorSet.setDuration(ANIMATION_DURATION_MS); |
| 240 mAnimatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); | 239 mAnimatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); |
| 241 mAnimatorSet.start(); | 240 mAnimatorSet.start(); |
| 242 } | 241 } |
| 243 } | 242 } |
| OLD | NEW |