06-03-2011 07:20 AM
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_SLI DE);
tr.setIntAttribute(TransitionContext.ATTR_DURATION , 1000);
tr.setIntAttribute(TransitionContext.ATTR_DIRECTIO N, 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 ?
Solved! Go to Solution.
06-03-2011 09:27 AM
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.LIGH
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_SLI
transition.setIntAttribute(TransitionContext.ATTR_
transition.setIntAttribute(TransitionContext.ATTR_
TransitionContext.DIRECTION_RIGHT);
transition.setIntAttribute(TransitionContext.ATTR_
TransitionContext.STYLE_PUSH);
UiEngineInstance engine = Ui.getUiEngineInstance();
engine.setTransition(null, _secondaryScreen, UiEngineInstance.TRIGGER_PUSH,
transition);
transition = new TransitionContext(TransitionContext.TRANSITION_FAD
transition.setIntAttribute(TransitionContext.ATTR_
transition.setIntAttribute(TransitionContext.ATTR_
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.LIGH
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_SLI
transition.setIntAttribute(TransitionContext.ATTR_
transition.setIntAttribute(TransitionContext.ATTR_
TransitionContext.DIRECTION_RIGHT);
transition.setIntAttribute(TransitionContext.ATTR_
TransitionContext.STYLE_PUSH);
UiEngineInstance engine = Ui.getUiEngineInstance();
engine.setTransition(null, _secondaryScreen, UiEngineInstance.TRIGGER_PUSH,
transition);
transition = new TransitionContext(TransitionContext.TRANSITION_FAD
transition.setIntAttribute(TransitionContext.ATTR_
transition.setIntAttribute(TransitionContext.ATTR_
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);
}
}
06-03-2011 11:22 AM - edited 06-03-2011 11:24 AM
thanx for replying
but I've read this example at
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.
06-03-2011 12:01 PM
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.
07-24-2012 08:45 AM
okay, so could you post the new working sample to help some of us here?
07-24-2012 09:26 AM - edited 07-24-2012 09:28 AM
******************* working sample*************************************
UiEngineInstance engine = Ui.getUiEngineInstance();
//this for push animation
TransitionContext transition = new TransitionContext(TransitionContext.TRANSITION_SLI
transition.setIntAttribute(TransitionContext.ATTR_
transition.setIntAttribute(TransitionContext.ATTR_
TransitionContext.DIRECTION_RIGHT);
transition.setIntAttribute(TransitionContext.ATTR_
TransitionContext.STYLE_PUSH);
engine.setTransition(null, screen, UiEngineInstance.TRIGGER_PUSH, transition);
//this for pop animation
transition = new TransitionContext(TransitionContext.TRANSITION_SLI
transition.setIntAttribute(TransitionContext.ATTR_
transition.setIntAttribute(TransitionContext.ATTR_
TransitionContext.DIRECTION_RIGHT);
engine.setTransition(screen, null, UiEngineInstance.TRIGGER_POP, transition);
UiApplication.getUiApplication().pushScreen(screen