Search in sources :

Example 1 with CommonTransitions

use of com.codename1.ui.animations.CommonTransitions in project CodenameOne by codenameone.

the class SwipeBackSupport method startBackTransition.

void startBackTransition(final Form currentForm, Form destination) {
    final Transition t = destination.getTransitionOutAnimator().copy(true);
    if (t instanceof CommonTransitions) {
        Transition originalTransition = currentForm.getTransitionOutAnimator();
        currentForm.setTransitionOutAnimator(CommonTransitions.createEmpty());
        Form blank = new Form() {

            protected boolean shouldSendPointerReleaseToOtherForm() {
                return true;
            }
        };
        blank.addPointerDraggedListener(pointerDragged);
        blank.addPointerReleasedListener(pointerReleased);
        blank.addPointerPressedListener(pointerPressed);
        blank.setTransitionInAnimator(CommonTransitions.createEmpty());
        blank.setTransitionOutAnimator(CommonTransitions.createEmpty());
        blank.show();
        currentForm.setTransitionOutAnimator(originalTransition);
        ((CommonTransitions) t).setMotion(new LazyValue<Motion>() {

            public Motion get(Object... args) {
                return new ManualMotion(((Integer) args[0]).intValue(), ((Integer) args[1]).intValue(), ((Integer) args[2]).intValue());
            }
        });
        t.init(currentForm, destination);
        t.initTransition();
        blank.setGlassPane(new Painter() {

            public void paint(Graphics g, Rectangle rect) {
                t.animate();
                t.paint(g);
            }
        });
    }
}
Also used : Graphics(com.codename1.ui.Graphics) Motion(com.codename1.ui.animations.Motion) CommonTransitions(com.codename1.ui.animations.CommonTransitions) Form(com.codename1.ui.Form) Transition(com.codename1.ui.animations.Transition) Painter(com.codename1.ui.Painter) Rectangle(com.codename1.ui.geom.Rectangle)

Aggregations

Form (com.codename1.ui.Form)1 Graphics (com.codename1.ui.Graphics)1 Painter (com.codename1.ui.Painter)1 CommonTransitions (com.codename1.ui.animations.CommonTransitions)1 Motion (com.codename1.ui.animations.Motion)1 Transition (com.codename1.ui.animations.Transition)1 Rectangle (com.codename1.ui.geom.Rectangle)1