OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.widget.bottomsheet; | 5 package org.chromium.chrome.browser.widget.bottomsheet; |
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.ObjectAnimator; | 9 import android.animation.ObjectAnimator; |
10 import android.animation.ValueAnimator; | 10 import android.animation.ValueAnimator; |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 private void cancelAnimation() { | 805 private void cancelAnimation() { |
806 if (mSettleAnimator == null) return; | 806 if (mSettleAnimator == null) return; |
807 mSettleAnimator.cancel(); | 807 mSettleAnimator.cancel(); |
808 mSettleAnimator = null; | 808 mSettleAnimator = null; |
809 } | 809 } |
810 | 810 |
811 /** | 811 /** |
812 * Creates the sheet's animation to a target state. | 812 * Creates the sheet's animation to a target state. |
813 * @param targetState The target state. | 813 * @param targetState The target state. |
814 */ | 814 */ |
815 private void createSettleAnimation(@SheetState int targetState) { | 815 private void createSettleAnimation(@SheetState final int targetState) { |
816 mTargetState = targetState; | 816 mTargetState = targetState; |
817 mSettleAnimator = ValueAnimator.ofFloat( | 817 mSettleAnimator = ValueAnimator.ofFloat( |
818 getSheetOffsetFromBottom(), getSheetHeightForState(targetState))
; | 818 getSheetOffsetFromBottom(), getSheetHeightForState(targetState))
; |
819 mSettleAnimator.setDuration(BASE_ANIMATION_DURATION_MS); | 819 mSettleAnimator.setDuration(BASE_ANIMATION_DURATION_MS); |
820 mSettleAnimator.setInterpolator(mInterpolator); | 820 mSettleAnimator.setInterpolator(mInterpolator); |
821 | 821 |
822 // When the animation is canceled or ends, reset the handle to null. | 822 // When the animation is canceled or ends, reset the handle to null. |
823 mSettleAnimator.addListener(new AnimatorListenerAdapter() { | 823 mSettleAnimator.addListener(new AnimatorListenerAdapter() { |
824 @Override | 824 @Override |
825 public void onAnimationEnd(Animator animator) { | 825 public void onAnimationEnd(Animator animator) { |
826 mSettleAnimator = null; | 826 mSettleAnimator = null; |
827 setInternalCurrentState(mTargetState); | 827 setInternalCurrentState(targetState); |
828 mTargetState = SHEET_STATE_NONE; | 828 mTargetState = SHEET_STATE_NONE; |
829 } | 829 } |
830 }); | 830 }); |
831 | 831 |
832 mSettleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListen
er() { | 832 mSettleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListen
er() { |
833 @Override | 833 @Override |
834 public void onAnimationUpdate(ValueAnimator animator) { | 834 public void onAnimationUpdate(ValueAnimator animator) { |
835 setSheetOffsetFromBottom((Float) animator.getAnimatedValue()); | 835 setSheetOffsetFromBottom((Float) animator.getAnimatedValue()); |
836 } | 836 } |
837 }); | 837 }); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 getContext(), mControlContainer, R.string.bottom_sheet_help_bubb
le_message); | 1141 getContext(), mControlContainer, R.string.bottom_sheet_help_bubb
le_message); |
1142 int inset = getContext().getResources().getDimensionPixelSize( | 1142 int inset = getContext().getResources().getDimensionPixelSize( |
1143 R.dimen.bottom_sheet_help_bubble_inset); | 1143 R.dimen.bottom_sheet_help_bubble_inset); |
1144 helpBubble.setInsetPx(0, inset, 0, inset); | 1144 helpBubble.setInsetPx(0, inset, 0, inset); |
1145 helpBubble.setDismissOnTouchInteraction(true); | 1145 helpBubble.setDismissOnTouchInteraction(true); |
1146 helpBubble.show(); | 1146 helpBubble.show(); |
1147 | 1147 |
1148 preferences.edit().putBoolean(BOTTOM_SHEET_HELP_BUBBLE_SHOWN, true).appl
y(); | 1148 preferences.edit().putBoolean(BOTTOM_SHEET_HELP_BUBBLE_SHOWN, true).appl
y(); |
1149 } | 1149 } |
1150 } | 1150 } |
OLD | NEW |