use of com.android.gallery3d.filtershow.category.CategoryView in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method dispatchTouchEvent.
public boolean dispatchTouchEvent(MotionEvent ev) {
if (mHandlingSwipeButton) {
int direction = CategoryView.HORIZONTAL;
if (mHandledSwipeView instanceof CategoryView) {
direction = ((CategoryView) mHandledSwipeView).getOrientation();
}
if (ev.getActionMasked() == MotionEvent.ACTION_MOVE) {
float delta = ev.getY() - mSwipeStartY;
float distance = mHandledSwipeView.getHeight();
if (direction == CategoryView.VERTICAL) {
delta = ev.getX() - mSwipeStartX;
mHandledSwipeView.setTranslationX(delta);
distance = mHandledSwipeView.getWidth();
} else {
mHandledSwipeView.setTranslationY(delta);
}
delta = Math.abs(delta);
float transparency = Math.min(1, delta / distance);
mHandledSwipeView.setAlpha(1.f - transparency);
mHandledSwipeViewLastDelta = delta;
}
if (ev.getActionMasked() == MotionEvent.ACTION_CANCEL || ev.getActionMasked() == MotionEvent.ACTION_UP) {
mHandledSwipeView.setTranslationX(0);
mHandledSwipeView.setTranslationY(0);
mHandledSwipeView.setAlpha(1.f);
mHandlingSwipeButton = false;
float distance = mHandledSwipeView.getHeight();
if (direction == CategoryView.VERTICAL) {
distance = mHandledSwipeView.getWidth();
}
if (mHandledSwipeViewLastDelta > distance) {
((SwipableView) mHandledSwipeView).delete();
}
}
return true;
}
return super.dispatchTouchEvent(ev);
}
Aggregations