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
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
Accepted Solution

regarding navigationMovement() mtehod

i have used navigationMovement() to swipe left or right the screen using slide transition ,first time when i swipe the screen to right the code is working , but when i swiped second time then my code did not work.  here is my code

public final class MyScreen extends MainScreen
{
    private boolean _pushed;
	/**
     * Creates a new MyScreen object
     */
    public MyScreen()
    {        
        // Set the displayed title of the screen       
        setTitle("MyTitle");
        add(new LabelField("A class extending the MainScreen class, which provides default standard"));
    }
    protected boolean navigationMovement(int dx,int dy,int status,int time)
    {
        try
        {
            
            if(dx > 0)
            {
            	UiApplication.getUiApplication().invokeLater(new Runnable() {
					
					public void run() {
						// TODO Auto-generated method stub
						UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
						push();     
					}
				});
            
            	//counter++;
            	//labl.setText("counter="+counter);
            	//System.out.println("="+counter);
            }
            if(dx < 0)
            {
            	UiApplication.getUiApplication().invokeLater(new Runnable() {
					
					public void run() {
						// TODO Auto-generated method stub
						UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
						pushsecond();     
						
					}
				});

            	//counter--;
            	//labl.setText("counter="+counter);
            	//System.out.println("="+counter);
            }
            if(dy < 0)
            {
                 System.out.println("UP : ");
                // Dialog.alert("UP : ");
            }
            if(dy > 0)
            {
                 System.out.println("DOWN : ");
                 //Dialog.alert("DOWN");
            }
            this.invalidate();
        }
        catch(Exception e)
        {
        	System.out.println("WError:"+e.toString());
        }
        return true;
    }
	public void pushsecond() {
		// TODO Auto-generated method stub
		    MyPreview screen = null;
		    TransitionContext transitionContextIn;
	        TransitionContext transitionContextOut;
	        
	        UiEngineInstance engine = Ui.getUiEngineInstance();         
	        screen = new MyPreview();  
	        
	        transitionContextIn = new TransitionContext(TransitionContext.TRANSITION_SLIDE);

	        transitionContextIn.setIntAttribute(TransitionContext.ATTR_DURATION, 500);
	        transitionContextIn.setIntAttribute(TransitionContext.ATTR_DIRECTION, TransitionContext.DIRECTION_LEFT);
	        
	        transitionContextOut = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
	        transitionContextOut.setIntAttribute(TransitionContext.ATTR_DURATION, 500);
	        transitionContextOut.setIntAttribute(TransitionContext.ATTR_DIRECTION, TransitionContext.DIRECTION_RIGHT);
	        transitionContextOut.setIntAttribute(TransitionContext.ATTR_KIND, TransitionContext.KIND_OUT);    
	                engine.setTransition(null, screen, UiEngineInstance.TRIGGER_PUSH, transitionContextIn);
	                engine.setTransition(screen, null, UiEngineInstance.TRIGGER_POP, transitionContextOut);
	                
	        synchronized(UiApplication.getEventLock())
	        {
	           UiApplication.getUiApplication().pushScreen(screen);   
	            _pushed = true;                      
	        }    
		
	}
	public void push() {
		// TODO Auto-generated method stub
        Preview screen = null;
        TransitionContext transitionContextIn;
        TransitionContext transitionContextOut;
        
        UiEngineInstance engine = Ui.getUiEngineInstance();         
        screen = new Preview();  
        transitionContextIn = new TransitionContext(TransitionContext.TRANSITION_SLIDE);

        transitionContextIn.setIntAttribute(TransitionContext.ATTR_DURATION, 500);
        transitionContextIn.setIntAttribute(TransitionContext.ATTR_DIRECTION, TransitionContext.DIRECTION_RIGHT); 
        
        transitionContextOut = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
        transitionContextOut.setIntAttribute(TransitionContext.ATTR_DURATION, 500);
        transitionContextOut.setIntAttribute(TransitionContext.ATTR_DIRECTION, TransitionContext.DIRECTION_RIGHT);
        transitionContextOut.setIntAttribute(TransitionContext.ATTR_KIND, TransitionContext.KIND_OUT);    
                engine.setTransition(null, screen, UiEngineInstance.TRIGGER_PUSH, transitionContextIn);
                engine.setTransition(screen, null, UiEngineInstance.TRIGGER_POP, transitionContextOut);
                
        synchronized(UiApplication.getEventLock())
        {
           UiApplication.getUiApplication().pushScreen(screen);   
            _pushed = true;                      
        }           

		
	}
}

 

 

Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900

Re: regarding navigationMovement() mtehod

plz anyone solve my issue
Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900

Re: regarding navigationMovement() mtehod

plz anyone solve my issue
Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: regarding navigationMovement() mtehod

Can you give us a more than "my code did not work.". 

 

http://www.catb.org/esr/faqs/smart-questions.html#beprecise

Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900

Re: regarding navigationMovement() mtehod

ok, when i swipe first time the screen was wiped with slide transition but when i swiped again then the screen is not swiped
for eg- i swiped left with navigationMovement, the screen is pushed with slide transition,looking like the screen is moving but when i swiped again left then the screen is not swiped,
Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: regarding navigationMovement() method

And when you debugged your code, what was being executed?  Does this apply in both directions?  Are you running a SImulator or not?  What OS are you using?  What steps have you taken to try to determine where the problem is?  Have you tried the process with and without transition?  Have you given us code that we can use to reproduce the problem? 

 

Have you read this?

http://supportforums.blackberry.com/t5/Java-Development/Information-to-include-when-posting-to-the-J...

 

We can help when you identify the problem more accurately and completely. 

Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900

Re: regarding navigationMovement() method

[ Edited ]

when i debug my code first time it's consuming the event and working fine .

yes this apply in both direction.

and i'm running on simulator and i'm using 5 Os.

no i'did not try this without transition but i when i swiped second time i think the event is not consuming to swipe the screen second time

 

Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: regarding navigationMovement() method

"when i debug my code first time it's consuming the event and working fine ."  So when you debug and go through each step in all situaitons it executes all the instructions in your code sample?

 

"yes this apply in both direction."  So if you start in one direction it wil then fail if you choose the same direction a second time or when you choose the other direction or does it not matter?  Can you give us a list of all the possible directions you can choose and what happens? 

 

"no i'did not try this without transition" Can you please try this without transition 

 

"i think the event is not consuming to swipe the screen second time"  Can you explain this in another way and explain the evidence that you have to support what you think. 

 

Finally, have you given us code that we can use to reproduce the problem?

Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900

Re: regarding navigationMovement() method

i think u did not got my point
my requirement is on every swipe of left or right i want to push a screen with slide transition.if u look at my code it swipes the only once but when i swipe the screen it did not consume the event in navgationmoment();
Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: regarding navigationMovement() method

[ Edited ]

I understand your requirement.  What I am trying to do here is help you find a problem in your code, by getting you to check things are working correctly or suggesting tests that will help determine where the problem actually is.  The checks I have asked you to do are exactly the same ones I would do in your situation. 

 

In fact I suspect the code you have supplied is working fine - the problem is elsewhere.  So given what we know, we can't tell you where the problem is at present anyway!  No, this does not mean that I want you to provide us with all your code.  If you work through a logical process of eliminating the possible causes of the problem, you will find out what the problem is yourself. 

 

What you seem to be expecting us to do is fix your code.  Rather than do that, it is a lot better if we help you fix your own code isn't it?  Then you will use these debugging skills for your future problems. 

 

More questions.  Which screen is on display at that time this fails?  Which screen will the trackpad be interacting with?

Please use plain text.