Merge "Lock out ResolverDrawerLayout dismissals during animations" into oc-dev
am: 33a030fa03
Change-Id: Ica063156bc487bd10d2c8af1a7520b71c1c31a88
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.internal.app;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.annotation.NonNull;
|
||||
import android.app.Activity;
|
||||
@@ -1136,8 +1138,10 @@ public class ChooserActivity extends ResolverActivity {
|
||||
* Set to true to reveal all service targets at once.
|
||||
*/
|
||||
public void setShowServiceTargets(boolean show) {
|
||||
mShowServiceTargets = show;
|
||||
notifyDataSetChanged();
|
||||
if (show != mShowServiceTargets) {
|
||||
mShowServiceTargets = show;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void insertServiceTarget(ChooserTargetInfo chooserTargetInfo) {
|
||||
@@ -1201,7 +1205,18 @@ public class ChooserActivity extends ResolverActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
mAnimator = ObjectAnimator.ofFloat(this, PROPERTY, from, to).setDuration(DURATION);
|
||||
mAnimator = ObjectAnimator.ofFloat(this, PROPERTY, from, to)
|
||||
.setDuration(DURATION);
|
||||
mAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mAdapter.onAnimationStart();
|
||||
}
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mAdapter.onAnimationEnd();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public RowScale setInterpolator(Interpolator interpolator) {
|
||||
@@ -1234,6 +1249,7 @@ public class ChooserActivity extends ResolverActivity {
|
||||
private final int mColumnCount = 4;
|
||||
private RowScale[] mServiceTargetScale;
|
||||
private final Interpolator mInterpolator;
|
||||
private int mAnimationCount = 0;
|
||||
|
||||
public ChooserRowAdapter(ChooserListAdapter wrappedAdapter) {
|
||||
mChooserListAdapter = wrappedAdapter;
|
||||
@@ -1302,6 +1318,21 @@ public class ChooserActivity extends ResolverActivity {
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
public void onAnimationStart() {
|
||||
final boolean lock = mAnimationCount == 0;
|
||||
mAnimationCount++;
|
||||
if (lock) {
|
||||
mResolverDrawerLayout.setDismissLocked(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimationEnd() {
|
||||
mAnimationCount--;
|
||||
if (mAnimationCount == 0) {
|
||||
mResolverDrawerLayout.setDismissLocked(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return (int) (
|
||||
|
||||
@@ -96,6 +96,8 @@ public class ResolverDrawerLayout extends ViewGroup {
|
||||
private OnDismissedListener mOnDismissedListener;
|
||||
private RunOnDismissedListener mRunOnDismissedListener;
|
||||
|
||||
private boolean mDismissLocked;
|
||||
|
||||
private float mInitialTouchX;
|
||||
private float mInitialTouchY;
|
||||
private float mLastTouchY;
|
||||
@@ -187,6 +189,10 @@ public class ResolverDrawerLayout extends ViewGroup {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setDismissLocked(boolean locked) {
|
||||
mDismissLocked = locked;
|
||||
}
|
||||
|
||||
private boolean isMoving() {
|
||||
return mIsDragging || !mScroller.isFinished();
|
||||
}
|
||||
@@ -229,6 +235,10 @@ public class ResolverDrawerLayout extends ViewGroup {
|
||||
mOnDismissedListener = listener;
|
||||
}
|
||||
|
||||
private boolean isDismissable() {
|
||||
return mOnDismissedListener != null && !mDismissLocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
final int action = ev.getActionMasked();
|
||||
@@ -296,7 +306,7 @@ public class ResolverDrawerLayout extends ViewGroup {
|
||||
mInitialTouchY = mLastTouchY = y;
|
||||
mActivePointerId = ev.getPointerId(0);
|
||||
final boolean hitView = findChildUnder(mInitialTouchX, mInitialTouchY) != null;
|
||||
handled = mOnDismissedListener != null || mCollapsibleHeight > 0;
|
||||
handled = isDismissable() || mCollapsibleHeight > 0;
|
||||
mIsDragging = hitView && handled;
|
||||
abortAnimation();
|
||||
}
|
||||
@@ -348,7 +358,7 @@ public class ResolverDrawerLayout extends ViewGroup {
|
||||
mIsDragging = false;
|
||||
if (!wasDragging && findChildUnder(mInitialTouchX, mInitialTouchY) == null &&
|
||||
findChildUnder(ev.getX(), ev.getY()) == null) {
|
||||
if (mOnDismissedListener != null) {
|
||||
if (isDismissable()) {
|
||||
dispatchOnDismissed();
|
||||
resetTouch();
|
||||
return true;
|
||||
@@ -362,7 +372,7 @@ public class ResolverDrawerLayout extends ViewGroup {
|
||||
mVelocityTracker.computeCurrentVelocity(1000);
|
||||
final float yvel = mVelocityTracker.getYVelocity(mActivePointerId);
|
||||
if (Math.abs(yvel) > mMinFlingVelocity) {
|
||||
if (mOnDismissedListener != null
|
||||
if (isDismissable()
|
||||
&& yvel > 0 && mCollapseOffset > mCollapsibleHeight) {
|
||||
smoothScrollTo(mCollapsibleHeight + mUncollapsibleHeight, yvel);
|
||||
mDismissOnScrollerFinished = true;
|
||||
@@ -656,7 +666,7 @@ public class ResolverDrawerLayout extends ViewGroup {
|
||||
@Override
|
||||
public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed) {
|
||||
if (!consumed && Math.abs(velocityY) > mMinFlingVelocity) {
|
||||
if (mOnDismissedListener != null
|
||||
if (isDismissable()
|
||||
&& velocityY < 0 && mCollapseOffset > mCollapsibleHeight) {
|
||||
smoothScrollTo(mCollapsibleHeight + mUncollapsibleHeight, velocityY);
|
||||
mDismissOnScrollerFinished = true;
|
||||
|
||||
Reference in New Issue
Block a user