Skip to content

Commit

Permalink
Update CameraView.java
Browse files Browse the repository at this point in the history
  • Loading branch information
EzequielAdrianM authored Feb 8, 2024
1 parent c1ab8c8 commit 0470e35
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
@VisibleForTesting TapGestureFinder mTapGestureFinder;
@VisibleForTesting ScrollGestureFinder mScrollGestureFinder;

private float x1,x2;
static final int MIN_SWIPE_DISTANCE = 150;

// Views
@VisibleForTesting GridLinesLayout mGridLinesLayout;
@VisibleForTesting MarkerLayout mMarkerLayout;
Expand Down Expand Up @@ -666,6 +669,32 @@ public boolean onTouchEvent(MotionEvent event) {
onGesture(mTapGestureFinder, options);
}

if(event.getAction() == MotionEvent.ACTION_DOWN) x1 = event.getX();
if(event.getAction() == MotionEvent.ACTION_UP) {
x2 = event.getX();
float deltaX = x2 - x1;
if(deltaX > MIN_SWIPE_DISTANCE) {
mUiHandler.post(new Runnable() {
@Override
public void run() {
for (CameraListener listener : mListeners) {
listener.onSwipeRight();
}
}
});
}
if (deltaX < MIN_SWIPE_DISTANCE) {
mUiHandler.post(new Runnable() {
@Override
public void run() {
for (CameraListener listener : mListeners) {
listener.onSwipeLeft();
}
}
});
}
}

return true;
}

Expand Down

0 comments on commit 0470e35

Please sign in to comment.