*/
@VisibleForTesting
void finishExpanding(boolean forceAbort, float velocity) {
+ finishExpanding(forceAbort, velocity, true /* allowAnimation */);
+ }
+
+ /**
+ * Finish the current expand motion
+ * @param forceAbort whether the expansion should be forcefully aborted and returned to the old
+ * state
+ * @param velocity the velocity this was expanded/ collapsed with
+ */
+ private void finishExpanding(boolean forceAbort, float velocity, boolean allowAnimation) {
if (!mExpanding) return;
if (DEBUG) Log.d(TAG, "scale in finishing on view: " + mResizedView);
mCallback.expansionStateChanged(false);
int naturalHeight = mScaler.getNaturalHeight();
float targetHeight = nowExpanded ? naturalHeight : mSmallSize;
- if (targetHeight != currentHeight && mEnabled) {
+ if (targetHeight != currentHeight && mEnabled && allowAnimation) {
mScaleAnimation.setFloatValues(targetHeight);
mScaleAnimation.setupStartValues();
final View scaledView = mResizedView;
}
/**
+ * Use this to abort any pending expansions in progress and force that there will be no
+ * animations.
+ */
+ public void cancelImmediately() {
+ cancel(false /* allowAnimation */);
+ }
+
+ /**
* Use this to abort any pending expansions in progress.
*/
public void cancel() {
- finishExpanding(true /* forceAbort */, 0f /* velocity */);
+ cancel(true /* allowAnimation */);
+ }
+
+ private void cancel(boolean allowAnimation) {
+ finishExpanding(true /* forceAbort */, 0f /* velocity */, allowAnimation);
clearView();
// reset the gesture detector
if (!mIsExpanded) {
setOwnScrollY(0);
mStatusBar.resetUserExpandedStates();
+ clearTemporaryViews();
+ clearUserLockedViews();
+ }
+ }
- // lets make sure nothing is in the overlay / transient anymore
- clearTemporaryViews(this);
- for (int i = 0; i < getChildCount(); i++) {
- ExpandableView child = (ExpandableView) getChildAt(i);
- if (child instanceof ExpandableNotificationRow) {
- ExpandableNotificationRow row = (ExpandableNotificationRow) child;
- clearTemporaryViews(row.getChildrenContainer());
- }
+ private void clearUserLockedViews() {
+ for (int i = 0; i < getChildCount(); i++) {
+ ExpandableView child = (ExpandableView) getChildAt(i);
+ if (child instanceof ExpandableNotificationRow) {
+ ExpandableNotificationRow row = (ExpandableNotificationRow) child;
+ row.setUserLocked(false);
+ }
+ }
+ }
+
+ private void clearTemporaryViews() {
+ // lets make sure nothing is in the overlay / transient anymore
+ clearTemporaryViews(this);
+ for (int i = 0; i < getChildCount(); i++) {
+ ExpandableView child = (ExpandableView) getChildAt(i);
+ if (child instanceof ExpandableNotificationRow) {
+ ExpandableNotificationRow row = (ExpandableNotificationRow) child;
+ clearTemporaryViews(row.getChildrenContainer());
}
}
}
if (changed) {
if (!mIsExpanded) {
mGroupManager.collapseAllGroups();
+ mExpandHelper.cancelImmediately();
}
updateNotificationAnimationStates();
updateChronometers();