3

I'm using the Fresco library, com.facebook.fresco:fresco:0.10.0. I'm trying to combine two effects that use the Facebook Application.

  1. Zoom To Point
  2. Swipe To Close

I created DoubleTapZoomableController class which extends of DefaultZoomableController that makes the effect to zoom correctly, but I don't know how to make this work with swipe to close. I tried a lot of alternatives but none of them make the swipe to close effect, because the ontouch listener method gets "confused" with the ACTION_UP and ACTION_DOWN. Sometimes it makes the swipe to close effect when I was trying to do the double tap effect.

I would like to know how to implement the "swipe to close" effect with the double tap effect. Is there any library o something like that with an example?

Here is my DoubleTapZoomableController class:

public class DoubleTapZoomableController extends DefaultZoomableController
    implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {

private final GestureDetector mGestureDetector;
public DoubleTapZoomableController(TransformGestureDetector gestureDetector, Context context) {
    super(gestureDetector);
    mGestureDetector = new GestureDetector(context, this);
    mGestureDetector.setOnDoubleTapListener(this);
}

public static DoubleTapZoomableController newInstance(Context context) {
    return new DoubleTapZoomableController(TransformGestureDetector.newInstance(), context);
}

@Override
public boolean onSingleTapConfirmed(MotionEvent event) {
    return false;
}

@Override
public boolean onDoubleTap(MotionEvent event) {
    PointF point = mapViewToImage(new PointF(event.getX(), event.getY()));
    if (getScaleFactor() > 1.0f) {
        zoomToImagePoint(1.0f, point, point,true, true, 300, null);
    } else {
        zoomToImagePoint(2.0f, point, point,true, true, 300, null);
    }
    return true;
}

@Override
public boolean onDoubleTapEvent(MotionEvent event) {
    return false;
}

@Override
public boolean onDown(MotionEvent event) {
    return false;
}

@Override
public void onShowPress(MotionEvent event) {
}

@Override
public boolean onSingleTapUp(MotionEvent event) {
    return false;
}

@Override
public boolean onScroll(MotionEvent event, MotionEvent event1, float v, float v1) {
    return false;
}

@Override
public void onLongPress(MotionEvent event) {
}

@Override
public boolean onFling(MotionEvent event, MotionEvent event1, float v, float v1) {
    return false;
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (isEnabled()) {
        mGestureDetector.onTouchEvent(event);
        return super.onTouchEvent(event);
    }
    return false;
}

swipe to close effect

JpCrow
  • 4,881
  • 4
  • 32
  • 46
Johanna A.
  • 63
  • 7

0 Answers0