How to create a Blackberry screen slide animation similar to the Blackberry App World?

Does anyone know how to use the Blackberry JDE API to create screen slide animations similar to the Featured Items screen in the Blackberry app world? I know that in BlackBerry 5.0 there is some transitional transition to accomplish this. But I'm looking to do this for OS version 4.6. It has a nice scroll effect using the scroll ball in blackberry bold.

Thanks.

+5
source share
2 answers

As an alternative to the screenshot / bitmap approach ...

Graphics.pushContext(..), . runnable . , .

:

class TransitionScreen extends Screen {
    private int transitionOffset;
    private boolean isTransitionHorizontal;
    private ScreenTransition currentTransition;

    public TransitionScreen(boolean isTransitionHorizontal) {
        this.isTransitionHorizontal = isTransitionHorizontal;

        transitionOffset = getTransitionMaximum(); // So the screen starts offset
    }

    protected void paint(Graphics graphics) {
        // use transitionOffset as x or y depending on isTransitionHorizontal
        graphics.pushContext(...);
    }

    protected void onExposed() {
        transitionToOffset(0);
    }

    protected void onObscured() {
        int target = getTransitionMaximum();

        transitionToOffset(target);
    }

    private int getTransitionMaximum() {
        return isTransitionHorizontal ? Display.getWidth() : Display.getHeight();
    }

    private void transitionToOffset(int target) {
        if (currentTransition != null) {
            currentTransition.stop();
        }

        currentTransition = new ScreenTransition(target);

        getApplication().invokeLater(currentTransition);
    }
}

class ScreenTransition implements Runnable {
    private boolean animating;
    private int target;

    public ScreenTransitionUpdater(int target) {
        this.target = target;
    }

    public void stop() {
        animating = false;
    }

    public void run() {
        while(animating) {
            Object eventLock = getApplication().getEventLock();

            synchronized(eventLock) {
                // Interpolate myOffset to target

                // Set animating = false if myOffset = target

                invalidate();
            }
        }
    }
}

>

, .

+4

0

All Articles