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.AnimatorSet; | 9 import android.animation.AnimatorSet; |
10 import android.animation.ObjectAnimator; | 10 import android.animation.ObjectAnimator; |
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 | 1053 |
1054 /** | 1054 /** |
1055 * Adds an observer to the bottom sheet. | 1055 * Adds an observer to the bottom sheet. |
1056 * @param observer The observer to add. | 1056 * @param observer The observer to add. |
1057 */ | 1057 */ |
1058 public void addObserver(BottomSheetObserver observer) { | 1058 public void addObserver(BottomSheetObserver observer) { |
1059 mObservers.addObserver(observer); | 1059 mObservers.addObserver(observer); |
1060 } | 1060 } |
1061 | 1061 |
1062 /** | 1062 /** |
| 1063 * Removes an observer to the bottom sheet. |
| 1064 * @param observer The observer to remove. |
| 1065 */ |
| 1066 public void removeObserver(BottomSheetObserver observer) { |
| 1067 mObservers.removeObserver(observer); |
| 1068 } |
| 1069 |
| 1070 /** |
1063 * Gets the target state of the sheet based on the sheet's height and veloci
ty. | 1071 * Gets the target state of the sheet based on the sheet's height and veloci
ty. |
1064 * @param sheetHeight The current height of the sheet. | 1072 * @param sheetHeight The current height of the sheet. |
1065 * @param yVelocity The current Y velocity of the sheet. This is only used f
or determining the | 1073 * @param yVelocity The current Y velocity of the sheet. This is only used f
or determining the |
1066 * scroll or fling direction. If this value is positive, th
e movement is from | 1074 * scroll or fling direction. If this value is positive, th
e movement is from |
1067 * bottom to top. | 1075 * bottom to top. |
1068 * @return The target state of the bottom sheet. | 1076 * @return The target state of the bottom sheet. |
1069 */ | 1077 */ |
1070 @SheetState | 1078 @SheetState |
1071 private int getTargetSheetState(float sheetHeight, float yVelocity) { | 1079 private int getTargetSheetState(float sheetHeight, float yVelocity) { |
1072 if (sheetHeight <= getMinOffset()) return SHEET_STATE_PEEK; | 1080 if (sheetHeight <= getMinOffset()) return SHEET_STATE_PEEK; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 getContext(), mControlContainer, R.string.bottom_sheet_help_bubb
le_message); | 1162 getContext(), mControlContainer, R.string.bottom_sheet_help_bubb
le_message); |
1155 int inset = getContext().getResources().getDimensionPixelSize( | 1163 int inset = getContext().getResources().getDimensionPixelSize( |
1156 R.dimen.bottom_sheet_help_bubble_inset); | 1164 R.dimen.bottom_sheet_help_bubble_inset); |
1157 helpBubble.setInsetPx(0, inset, 0, inset); | 1165 helpBubble.setInsetPx(0, inset, 0, inset); |
1158 helpBubble.setDismissOnTouchInteraction(true); | 1166 helpBubble.setDismissOnTouchInteraction(true); |
1159 helpBubble.show(); | 1167 helpBubble.show(); |
1160 | 1168 |
1161 preferences.edit().putBoolean(BOTTOM_SHEET_HELP_BUBBLE_SHOWN, true).appl
y(); | 1169 preferences.edit().putBoolean(BOTTOM_SHEET_HELP_BUBBLE_SHOWN, true).appl
y(); |
1162 } | 1170 } |
1163 } | 1171 } |
OLD | NEW |