Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Super Contributor
tolmachevroman
Posts: 257
Registered: ‎05-05-2011
My Device: 9700
My Carrier: AT&T
Accepted Solution

Transition to another screen

Hi everyone,

 I'm trying to implement screen transition, but nothing happens - newly pushed screen appears momentally, without any transitions at all. No errors in debugger. What I do is:

 

LevelCompleteSplashScreen spl = new LevelCompleteSplashScreen();
    	TransitionContext tr = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
    	tr.setIntAttribute(TransitionContext.ATTR_DURATION, 1000);
    	tr.setIntAttribute(TransitionContext.ATTR_DIRECTION, TransitionContext.DIRECTION_RIGHT);
    	tr.setIntAttribute(TransitionContext.ATTR_STYLE, TransitionContext.STYLE_PUSH);

    	Ui.getUiEngineInstance().setTransition(null, spl, UiEngineInstance.TRIGGER_PUSH, tr);

   and after some event in my app I just push this spl. I checked TransitionContext instance, it is not null, but it doesn't work. How do I do such a simple transition ?

Please use plain text.
Developer
ahmadahmad
Posts: 404
Registered: ‎05-31-2011
My Device: curve
My Carrier: devel

Re: Transition to another screen

here a simple

 

 

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.decor.*;
public class ScreenTransitionSample extends UiApplication implements
FieldChangeListener {
private Screen _secondaryScreen;
private Runnable _popRunnable;
public static void main(String[] args) {
ScreenTransitionSample theApp = new ScreenTransitionSample ();
theApp.enterEventDispatcher();
}
public ScreenTransitionSample () {
_secondaryScreen = new FullScreen();
_secondaryScreen.setBackground(
BackgroundFactory.createSolidBackground(Color.LIGHTBLUE) );
LabelField labelField = new LabelField("The screen closes automatically in
two seconds by using a fade transition");
_secondaryScreen.add(labelField);
TransitionContext transition = new
TransitionContext(TransitionContext.TRANSITION_SLIDE);
transition.setIntAttribute(TransitionContext.ATTR_DURATION, 500);
transition.setIntAttribute(TransitionContext.ATTR_DIRECTION,
TransitionContext.DIRECTION_RIGHT);
transition.setIntAttribute(TransitionContext.ATTR_STYLE,
TransitionContext.STYLE_PUSH);
UiEngineInstance engine = Ui.getUiEngineInstance();
engine.setTransition(null, _secondaryScreen, UiEngineInstance.TRIGGER_PUSH,
transition);
transition = new TransitionContext(TransitionContext.TRANSITION_FADE);
transition.setIntAttribute(TransitionContext.ATTR_DURATION, 500);
transition.setIntAttribute(TransitionContext.ATTR_KIND,
TransitionContext.KIND_OUT);
engine.setTransition(_secondaryScreen, null, UiEngineInstance.TRIGGER_POP,
transition);
MainScreen baseScreen = new MainScreen();
baseScreen.setTitle("Screen Transition Sample");
ButtonField buttonField = new ButtonField("View Transition",
ButtonField.CONSUME_CLICK) ;
buttonField.setChangeListener(this);
baseScreen.add(buttonField);
pushScreen(baseScreen);
_popRunnable = new Runnable() {
public void run() {
popScreen(_secondaryScreen);
}
};
}
public void fieldChanged(Field field, int context)
{
pushScreen(_secondaryScreen);
invokeLater(_popRunnable, 2000, false);
}
}

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.decor.*;
public class ScreenTransitionSample extends UiApplication implements
FieldChangeListener {
private Screen _secondaryScreen;
private Runnable _popRunnable;
public static void main(String[] args) {
ScreenTransitionSample theApp = new ScreenTransitionSample ();
theApp.enterEventDispatcher();
}
public ScreenTransitionSample () {
_secondaryScreen = new FullScreen();
_secondaryScreen.setBackground(
BackgroundFactory.createSolidBackground(Color.LIGHTBLUE) );
LabelField labelField = new LabelField("The screen closes automatically in
two seconds by using a fade transition");
_secondaryScreen.add(labelField);
TransitionContext transition = new
TransitionContext(TransitionContext.TRANSITION_SLIDE);
transition.setIntAttribute(TransitionContext.ATTR_DURATION, 500);
transition.setIntAttribute(TransitionContext.ATTR_DIRECTION,
TransitionContext.DIRECTION_RIGHT);
transition.setIntAttribute(TransitionContext.ATTR_STYLE,
TransitionContext.STYLE_PUSH);
UiEngineInstance engine = Ui.getUiEngineInstance();
engine.setTransition(null, _secondaryScreen, UiEngineInstance.TRIGGER_PUSH,
transition);
transition = new TransitionContext(TransitionContext.TRANSITION_FADE);
transition.setIntAttribute(TransitionContext.ATTR_DURATION, 500);
transition.setIntAttribute(TransitionContext.ATTR_KIND,
TransitionContext.KIND_OUT);
engine.setTransition(_secondaryScreen, null, UiEngineInstance.TRIGGER_POP,
transition);
MainScreen baseScreen = new MainScreen();
baseScreen.setTitle("Screen Transition Sample");
ButtonField buttonField = new ButtonField("View Transition",
ButtonField.CONSUME_CLICK) ;
buttonField.setChangeListener(this);
baseScreen.add(buttonField);
pushScreen(baseScreen);
_popRunnable = new Runnable() {
public void run() {
popScreen(_secondaryScreen);
}
};
}
public void fieldChanged(Field field, int context)
{
pushScreen(_secondaryScreen);
invokeLater(_popRunnable, 2000, false);
}
}

Please use plain text.
Super Contributor
tolmachevroman
Posts: 257
Registered: ‎05-05-2011
My Device: 9700
My Carrier: AT&T

Re: Transition to another screen

[ Edited ]

thanx for replying :smileyhappy: but I've read this example at

http://docs.blackberry.com/en/developers/deliverables/11958/Screen_transitions_detailed_overview_806...

 

The reason I created new post is that I face problems implementing this example. I tried to follow this as closely as possible, but no results so far.

 

And a small notice - you can use code button on the panel to insert chunks, its much more readable.

Please use plain text.
Super Contributor
tolmachevroman
Posts: 257
Registered: ‎05-05-2011
My Device: 9700
My Carrier: AT&T

Re: Transition to another screen

Ok, finally I got things working. I guess the reason was this part:

 

UiApplication.getUiApplication().pushScreen(new LevelCompleteSplashScreen());

   I misunderstood and didn't use explicitly created spl. Now I just replaced this new instance with spl and transition works. Thanks for everyone reading and spending your time. 

 

 

Please use plain text.
New Contributor
rocketsciencegh
Posts: 4
Registered: ‎06-12-2012
My Device: 8320
My Carrier: AT&T

Re: Transition to another screen

okay, so could you post the new working sample to help some of us here?

Please use plain text.
Developer
kamal_nigam
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10
My Carrier: Orange

Re: Transition to another screen

[ Edited ]

******************* working sample*************************************

 

UiEngineInstance engine = Ui.getUiEngineInstance();

//this for push animation

 

TransitionContext transition = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
transition.setIntAttribute(TransitionContext.ATTR_DURATION, 500);
transition.setIntAttribute(TransitionContext.ATTR_DIRECTION,
TransitionContext.DIRECTION_RIGHT);
transition.setIntAttribute(TransitionContext.ATTR_STYLE,
TransitionContext.STYLE_PUSH);
engine.setTransition(null, screen, UiEngineInstance.TRIGGER_PUSH, transition);

 

//this for pop animation

transition = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
transition.setIntAttribute(TransitionContext.ATTR_DURATION, 500);
transition.setIntAttribute(TransitionContext.ATTR_DIRECTION,
TransitionContext.DIRECTION_RIGHT);
engine.setTransition(screen, null, UiEngineInstance.TRIGGER_POP, transition);

 

UiApplication.getUiApplication().pushScreen(screen); (screen is object of main screen which you are going to push into stack)

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
Please use plain text.