| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.banners; | 5 package org.chromium.chrome.browser.banners; |
| 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; |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 void createVerticalSnapAnimation(boolean visible) { | 380 void createVerticalSnapAnimation(boolean visible) { |
| 381 float translationY = visible ? 0.0f : mTotalHeight; | 381 float translationY = visible ? 0.0f : mTotalHeight; |
| 382 float yDifference = Math.abs(translationY - getTranslationY()) / mTotalH
eight; | 382 float yDifference = Math.abs(translationY - getTranslationY()) / mTotalH
eight; |
| 383 long duration = (long) (MS_ANIMATION_DURATION * yDifference); | 383 long duration = (long) (MS_ANIMATION_DURATION * yDifference); |
| 384 createAnimation(1.0f, 0, translationY, duration, false); | 384 createAnimation(1.0f, 0, translationY, duration, false); |
| 385 } | 385 } |
| 386 | 386 |
| 387 /** | 387 /** |
| 388 * Dismisses the View, animating it moving vertically off of the screen if n
eeded. | 388 * Dismisses the View, animating it moving vertically off of the screen if n
eeded. |
| 389 */ | 389 */ |
| 390 void dismiss() { | 390 protected void dismiss() { |
| 391 if (getParent() == null) return; | 391 if (getParent() == null) return; |
| 392 | 392 |
| 393 float translationY = mTotalHeight; | 393 float translationY = mTotalHeight; |
| 394 float yDifference = Math.abs(translationY - getTranslationY()) / mTotalH
eight; | 394 float yDifference = Math.abs(translationY - getTranslationY()) / mTotalH
eight; |
| 395 long duration = (long) (MS_ANIMATION_DURATION * yDifference); | 395 long duration = (long) (MS_ANIMATION_DURATION * yDifference); |
| 396 createAnimation(1.0f, 0, translationY, duration, true); | 396 createAnimation(1.0f, 0, translationY, duration, true); |
| 397 } | 397 } |
| 398 | 398 |
| 399 /** | 399 /** |
| 400 * Calculates how transparent the View should be. | 400 * Calculates how transparent the View should be. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 /** | 523 /** |
| 524 * Called when the View has been clicked. | 524 * Called when the View has been clicked. |
| 525 */ | 525 */ |
| 526 protected abstract void onViewClicked(); | 526 protected abstract void onViewClicked(); |
| 527 | 527 |
| 528 /** | 528 /** |
| 529 * Called when the View needs to show that it's been pressed. | 529 * Called when the View needs to show that it's been pressed. |
| 530 */ | 530 */ |
| 531 protected abstract void onViewPressed(MotionEvent event); | 531 protected abstract void onViewPressed(MotionEvent event); |
| 532 } | 532 } |
| OLD | NEW |