Merge "Fixed the motion when expanding notification groups" into nyc-dev
This commit is contained in:
@@ -535,31 +535,43 @@ public class ExpandHelper implements Gefingerpoken {
|
|||||||
boolean nowExpanded;
|
boolean nowExpanded;
|
||||||
int naturalHeight = mScaler.getNaturalHeight();
|
int naturalHeight = mScaler.getNaturalHeight();
|
||||||
if (wasClosed) {
|
if (wasClosed) {
|
||||||
nowExpanded = (force || currentHeight > mOldHeight);
|
nowExpanded = (force || currentHeight > mOldHeight && velocity >= 0);
|
||||||
} else {
|
} else {
|
||||||
nowExpanded = !force && currentHeight >= mOldHeight;
|
nowExpanded = !force && (currentHeight >= mOldHeight || velocity > 0);
|
||||||
}
|
}
|
||||||
nowExpanded |= mNaturalHeight == mSmallSize;
|
nowExpanded |= mNaturalHeight == mSmallSize;
|
||||||
if (mScaleAnimation.isRunning()) {
|
if (mScaleAnimation.isRunning()) {
|
||||||
mScaleAnimation.cancel();
|
mScaleAnimation.cancel();
|
||||||
}
|
}
|
||||||
mCallback.setUserExpandedChild(mResizedView, nowExpanded);
|
|
||||||
mCallback.expansionStateChanged(false);
|
mCallback.expansionStateChanged(false);
|
||||||
float targetHeight = nowExpanded ? naturalHeight : mSmallSize;
|
float targetHeight = nowExpanded ? naturalHeight : mSmallSize;
|
||||||
if (targetHeight != currentHeight) {
|
if (targetHeight != currentHeight) {
|
||||||
mScaleAnimation.setFloatValues(targetHeight);
|
mScaleAnimation.setFloatValues(targetHeight);
|
||||||
mScaleAnimation.setupStartValues();
|
mScaleAnimation.setupStartValues();
|
||||||
final View scaledView = mResizedView;
|
final View scaledView = mResizedView;
|
||||||
|
final boolean expand = nowExpanded;
|
||||||
mScaleAnimation.addListener(new AnimatorListenerAdapter() {
|
mScaleAnimation.addListener(new AnimatorListenerAdapter() {
|
||||||
|
public boolean mCancelled;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
|
if (!mCancelled) {
|
||||||
|
mCallback.setUserExpandedChild(scaledView, expand);
|
||||||
|
}
|
||||||
mCallback.setUserLockedChild(scaledView, false);
|
mCallback.setUserLockedChild(scaledView, false);
|
||||||
mScaleAnimation.removeListener(this);
|
mScaleAnimation.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationCancel(Animator animation) {
|
||||||
|
mCancelled = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
velocity = nowExpanded == velocity >= 0 ? velocity : 0;
|
||||||
mFlingAnimationUtils.apply(mScaleAnimation, currentHeight, targetHeight, velocity);
|
mFlingAnimationUtils.apply(mScaleAnimation, currentHeight, targetHeight, velocity);
|
||||||
mScaleAnimation.start();
|
mScaleAnimation.start();
|
||||||
} else {
|
} else {
|
||||||
|
mCallback.setUserExpandedChild(mResizedView, nowExpanded);
|
||||||
mCallback.setUserLockedChild(mResizedView, false);
|
mCallback.setUserLockedChild(mResizedView, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user