use of com.android.systemui.recents.views.TaskView in project android_frameworks_base by crdroidandroid.
the class SwipeHelper method onTouchEvent.
public boolean onTouchEvent(MotionEvent ev) {
if (mLongPressSent) {
return true;
}
if (!mDragging) {
if (mCallback.getChildAtPosition(ev) != null) {
// We are dragging directly over a card, make sure that we also catch the gesture
// even if nobody else wants the touch event.
onInterceptTouchEvent(ev);
return true;
} else {
// We are not doing anything, make sure the long press callback
// is not still ticking like a bomb waiting to go off.
removeLongPressCallback();
return false;
}
}
mVelocityTracker.addMovement(ev);
final int action = ev.getAction();
switch(action) {
case MotionEvent.ACTION_OUTSIDE:
case MotionEvent.ACTION_MOVE:
if (mCurrView != null) {
float delta = getPos(ev) - mInitialTouchPos;
float absDelta = Math.abs(delta);
if (absDelta >= getFalsingThreshold()) {
mTouchAboveFalsingThreshold = true;
}
// maxScrollDistance
if (CONSTRAIN_SWIPE && !mCallback.canChildBeDismissed(mCurrView)) {
float size = getSize(mCurrView);
float maxScrollDistance = 0.25f * size;
if (absDelta >= size) {
delta = delta > 0 ? maxScrollDistance : -maxScrollDistance;
} else {
delta = maxScrollDistance * (float) Math.sin((delta / size) * (Math.PI / 2));
}
}
setTranslation(mCurrView, mTranslation + delta);
updateSwipeProgressFromOffset(mCurrView, mCanCurrViewBeDimissed);
onMoveUpdate(mCurrView, mTranslation + delta, delta);
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
if (mCurrView == null) {
break;
}
mVelocityTracker.computeCurrentVelocity(1000, /* px/sec */
getMaxVelocity());
float velocity = getVelocity(mVelocityTracker);
if (!handleUpEvent(ev, mCurrView, velocity, getTranslation(mCurrView))) {
if (isDismissGesture(ev)) {
// flingadingy
TaskView mTaskView = (TaskView) mCurrView;
Task mTask = mTaskView.getTask();
if (mTask.isLockedTask) {
// snappity
mCallback.onDragCancelled(mCurrView);
snapChild(mCurrView, 0, /* leftTarget */
velocity);
} else {
// flingadingy
dismissChild(mCurrView, velocity, !swipedFastEnough());
}
} else {
// snappity
mCallback.onDragCancelled(mCurrView);
snapChild(mCurrView, 0, /* leftTarget */
velocity);
}
mCurrView = null;
}
mDragging = false;
break;
}
return true;
}
use of com.android.systemui.recents.views.TaskView in project android_frameworks_base by ResurrectionRemix.
the class SwipeHelper method onTouchEvent.
public boolean onTouchEvent(MotionEvent ev) {
if (mLongPressSent) {
return true;
}
if (!mDragging) {
if (mCallback.getChildAtPosition(ev) != null) {
// We are dragging directly over a card, make sure that we also catch the gesture
// even if nobody else wants the touch event.
onInterceptTouchEvent(ev);
return true;
} else {
// We are not doing anything, make sure the long press callback
// is not still ticking like a bomb waiting to go off.
removeLongPressCallback();
return false;
}
}
mVelocityTracker.addMovement(ev);
final int action = ev.getAction();
switch(action) {
case MotionEvent.ACTION_OUTSIDE:
case MotionEvent.ACTION_MOVE:
if (mCurrView != null) {
float delta = getPos(ev) - mInitialTouchPos;
float absDelta = Math.abs(delta);
if (absDelta >= getFalsingThreshold()) {
mTouchAboveFalsingThreshold = true;
}
// maxScrollDistance
if (CONSTRAIN_SWIPE && !mCallback.canChildBeDismissed(mCurrView)) {
float size = getSize(mCurrView);
float maxScrollDistance = 0.25f * size;
if (absDelta >= size) {
delta = delta > 0 ? maxScrollDistance : -maxScrollDistance;
} else {
delta = maxScrollDistance * (float) Math.sin((delta / size) * (Math.PI / 2));
}
}
setTranslation(mCurrView, mTranslation + delta);
updateSwipeProgressFromOffset(mCurrView, mCanCurrViewBeDimissed);
onMoveUpdate(mCurrView, mTranslation + delta, delta);
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
if (mCurrView == null) {
break;
}
mVelocityTracker.computeCurrentVelocity(1000, /* px/sec */
getMaxVelocity());
float velocity = getVelocity(mVelocityTracker);
if (!handleUpEvent(ev, mCurrView, velocity, getTranslation(mCurrView))) {
if (isDismissGesture(ev)) {
// flingadingy
TaskView mTaskView = (TaskView) mCurrView;
Task mTask = mTaskView.getTask();
if (Recents.sLockedTasks.contains(mTask)) {
// snappity
mCallback.onDragCancelled(mCurrView);
snapChild(mCurrView, 0, /* leftTarget */
velocity);
} else {
// flingadingy
dismissChild(mCurrView, velocity, !swipedFastEnough());
}
} else {
// snappity
mCallback.onDragCancelled(mCurrView);
snapChild(mCurrView, 0, /* leftTarget */
velocity);
}
mCurrView = null;
}
mDragging = false;
break;
}
return true;
}