Blackberry screen navigation probelm
Posted
by
dalandroid
on Stack Overflow
See other posts from Stack Overflow
or by dalandroid
Published on 2012-03-30T13:54:01Z
Indexed on
2012/04/02
5:30 UTC
Read the original article
Hit count: 171
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?
© Stack Overflow or respective owner