2012-03-30 4 views
0

私はスクリーンネームを持っていますDownloaderScreenスクリーンが始まるといくつかのファイルがダウンロードされ、ダウンロードが完了すると自動的に次のスクリーンに進みます。私は次のコードを使用しています。ブラックベリースクリーンナビゲーション

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()); 
       } 
      }); 
     } 
} 

コードが正常に動作していると開始は、ファイルをダウンロードし、ダウンロードが完了すると、それは次の画面に前進されます。しかし、ダウンロードするファイルがない場合は、配列の長さが0であるphraseListは、それは進んでいません。私のコードの問題は何ですか?

答えて

1

にコードがGuageFieldは、長さがゼロの場合は0から0に行くのが好き、GuageFieldを追加しませんしません。

1

変更

if(phraseList.length!=0){ 

     for(int i=0; i < phraseList.length ; i++){// 
      gaugeField.setValue(i); 
      // code for download 
     } 
     goToNext(); 

    } 
    else{ 
     goToNext(); //if nothing to download, then it will goto the next screen. 
     }