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
Regular Contributor
Posts: 55
Registered: ‎09-01-2010
My Device: Not Specified
Accepted Solution

Screen navigation probelm

I have a Screen name  DownloaderScreen when the screen start it will start download some file and when download is complete it will go forward to next screen autometically. I using the following code.

    public DownloaderScreen() {
            super(NO_VERTICAL_SCROLL | NO_HORIZONTAL_SCROLL | USE_ALL_HEIGHT
                    | USE_ALL_WIDTH);
            
            this.application = UiApplication.getUiApplication();
            HorizontalFieldManager outerBlock = new HorizontalFieldManager(USE_ALL_HEIGHT);
            VerticalFieldManager innerBlock = new VerticalFieldManager(USE_ALL_WIDTH | FIELD_VCENTER);
            innerBlock.setPadding(0, 10, 0, 10);
            outerBlock.setBackground(BackgroundFactory
                    .createBitmapBackground(LangValue.dlBgimg));
            outerBlock.add(innerBlock);
            add(outerBlock);
                
            phraseHelper = new PhraseHelper();
            final String[][] phraseList = phraseHelper.getDownloadList();
            
            gaugeField = new GaugeField("Downloading  ", 0, phraseList.length, 0, GaugeField.PERCENT);
            innerBlock.add(gaugeField);
            
            Thread dlTread = new Thread() {
                public void run() {
                    startDownload(phraseList);
                }
            };
            dlTread.start();
            
        }
    
    private void startDownload(String[][] phraseList){
            
            if(phraseList.length!=0){
            
                for(int i=0; i < phraseList.length ; i++){//
                   gaugeField.setValue(i);
                   // code for download    
                }
            }
            goToNext();
        }
    
    private void goToNext() {
    
    final Screen currentScreen = application.getActiveScreen();  
    
        if (UiApplication.isEventDispatchThread()) {  
            application.popScreen(currentScreen);  
            application.pushScreen(new HomeScreen());  
            } else {  
                application.invokeLater(new Runnable() {  
                    public void run() {  
                        application.popScreen(currentScreen);  
                        application.pushScreen(new HomeScreen());  
                    }  
                });  
            }
    }


The code is working fine and starts download files and when download is completed it is going forward to next screen. But when there is no file to download `phraseList` array length is zero, it is not going forward. What is problem in my code?

Developer
Posts: 19,624
Registered: ‎07-14-2008
My Device: Not Specified

Re: Screen navigation problem

Per haps the GuageField doesn't like going from 0 to 0? 

 

The easiest way to investigate this would be for you to debug the code and step through the processing for this case and see where it fails.  We are just guessing here.