Code example for ViewSwitcher

Methods: getCurrentView, invalidate, showNext

0
      progressBar.setMax(totalSize);
      progressBar.setProgress(bytesDone);
    } else { 
      progressDetails.setText(String.format(PROGRESS_FORMAT, bytesDone / 1024));
    } 
    progressDisplay.invalidate();
  } 
 
  /** 
   * Switch the UI to display either a progress bar or a spinner with details 
   * about download progress. 
   * 
   * @param displayBar if {@code true} will display progress bar, otherwise will 
   * display spinner and text view with downloaded byte count 
   */ 
  private void displayProgressBar(boolean displayBar) {
    boolean needsSwitching =
        (displayBar ? progressDisplay.getCurrentView() != progressBar :
                      progressDisplay.getCurrentView() == progressBar);
    if (needsSwitching) {
      progressDisplay.showNext();
    } 
  } 
 
  private void cancelDownload() { 
    if (downloadTask != null) {