import android.content.Context;
import android.view.GestureDetector;
+import android.view.InputDevice;
+import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
boolean onSingleTapUp(float x, float y);
boolean onDoubleTap(float x, float y);
boolean onScroll(float x, float y, float dx, float dy);
+ boolean onMouseScroll(float hscroll, float vscroll);
boolean onFling(float velocityX, float velocityY);
boolean onScaleBegin(float focusX, float focusY);
boolean onScale(float focusX, float focusY, float scale);
return (gestureProcessed | scaleProcessed);
}
+ public boolean onGenericMotionEvent(MotionEvent event) {
+ if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_SCROLL: {
+ final float hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
+ final float vscroll = -event.getAxisValue(MotionEvent.AXIS_VSCROLL);
+
+ if (hscroll != 0.0f || vscroll != 0.0f) {
+ mListener.onMouseScroll(hscroll, vscroll);
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
private class MyGestureListener
extends GestureDetector.SimpleOnGestureListener {
@Override
}
@Override
+ public boolean onMouseScroll(float hscroll, float vscroll) {
+ if (mFilmstripContentTranslationProgress == 0f) {
+ return mFilmstripGestureListener.onMouseScroll(hscroll, vscroll);
+ }
+ return false;
+ }
+
+ @Override
public boolean onSingleTapUp(float x, float y) {
if (mFilmstripContentTranslationProgress == 0f) {
return mFilmstripGestureListener.onSingleTapUp(x, y);
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.SparseArray;
+import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
// Only check for intercepting touch events within first 500ms
private static final int SWIPE_TIME_OUT = 500;
private static final int DECELERATION_FACTOR = 4;
+ private static final float MOUSE_SCROLL_FACTOR = 128f;
private CameraActivity mActivity;
private FilmstripGestureRecognizer mGestureRecognizer;
return mGestureRecognizer.onTouchEvent(ev);
}
+ @Override
+ public boolean onGenericMotionEvent(MotionEvent ev) {
+ mGestureRecognizer.onGenericMotionEvent(ev);
+ return true;
+ }
+
FilmstripGestureRecognizer.Listener getGestureListener() {
return mGestureListener;
}
}
@Override
+ public boolean onMouseScroll(float hscroll, float vscroll) {
+ final float scroll;
+
+ hscroll *= MOUSE_SCROLL_FACTOR;
+ vscroll *= MOUSE_SCROLL_FACTOR;
+
+ if (vscroll != 0f) {
+ scroll = vscroll;
+ } else {
+ scroll = hscroll;
+ }
+
+ if (inFullScreen()) {
+ onFling(-scroll, 0f);
+ } else if (inZoomView()) {
+ onScroll(0f, 0f, hscroll, vscroll);
+ } else {
+ onScroll(0f, 0f, scroll, 0f);
+ }
+
+ return true;
+ }
+
+ @Override
public boolean onFling(float velocityX, float velocityY) {
final ViewItem currItem = mViewItem[mCurrentItem];
if (currItem == null) {