Sets the download state and notifies the progress listener.

@param downloadState value to set to
429064
private void updateStateAndNotifyListener(DownloadState downloadState) throws IOException {
    this.downloadState = downloadState;
    if (progressListener != null) {
      progressListener.progressChanged(this);
    }
  }
1117854
public void download(OutputStream output, ProgressListener listener) {
        URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.fileID, this.getID());
        BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET");
        BoxAPIResponse response = request.send();
        InputStream input = response.getBody(listener);

        long totalRead = 0;
        byte[] buffer = new byte[BUFFER_SIZE];
        try {
            int n = input.read(buffer);
            totalRead += n;
            while (n != -1) {
                output.write(buffer, 0, n);
                n = input.read(buffer);
                totalRead += n;
            }
        } catch (IOException e) {
            throw new BoxAPIException("Couldn't connect to the Box API due to a network error.", e);
        }

        response.disconnect();
    }
211754
private void updateProgress(DownloadRequest request, long bytesWritten, long totalBytes) {
    long currentTimestamp = System.currentTimeMillis();
    if (bytesWritten != totalBytes
        && currentTimestamp - lastProgressTimestamp < request.progressInterval()) {
      return;
    }

    /* save progress timestamp */
    lastProgressTimestamp = currentTimestamp;

    if (!request.isCanceled()) {
      delivery.postProgress(request, bytesWritten, totalBytes);
    }
  }
1223848
public void setProgress(int progress) {
        if (mProgress != progress) {
            mProgress = progress;
            if (mOnCircularSeekBarChangeListener != null) {
                mOnCircularSeekBarChangeListener.onProgressChanged(this, progress, false);
            }

            recalculateAll();
            invalidate();
        }
    }
953690
@Override
    public void transferProgressed(TransferEvent event) {
        TransferResource resource = event.getResource();

        long lastTransferred = downloads.get(resource);
        long transferred = event.getTransferredBytes();

        if (transferred - lastTransferred >= TRANSFER_THRESHOLD) {
            downloads.put(resource, Long.valueOf(transferred));
            long total = resource.getContentLength();
            log.finer(getStatus(transferred, total) + ", ");
        }
    }
20859
public void setProgress(int progress) {
    if (progress > mMax || progress < 0) {
      throw new IllegalArgumentException(
          String.format("Progress (%d) must be between %d and %d", progress, 0, mMax));
    }
    mProgress = progress;
    invalidate();
  }
988688
protected final synchronized void setState(int newState)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && // d527372
            TEBeanLifeCycleInfo.isTraceEnabled())
            TEBeanLifeCycleInfo.traceBeanState(state, getStateName(state), newState,
                                               getStateName(newState)); // d167264

        state = newState;
    }
615464
public synchronized void setDeleteInProgress(boolean deleteInProgress)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "setDeleteInProgress");

        _deleteInProgress = deleteInProgress;

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "setDeleteInProgress", Boolean.valueOf(_deleteInProgress));
    }
265259
public void setStatus(BounceProxyStatus status) throws IllegalStateException {
        // this checks if the transition is valid
        if (this.status.isValidTransition(status)) {
            this.status = status;
        } else {
            throw new IllegalStateException("Illegal status transition from " + this.status + " to " + status);
        }
    }
147118
@TaskAction
    public void download() throws IOException {
        action.execute();
        
        // handle 'upToDate'
        try {
            if (action.isUpToDate()) {
                Method getState = this.getClass().getMethod("getState");
                Object state = getState.invoke(this);
                try {
                    // prior to Gradle 3.2 we needed to do this
                    Method upToDate = state.getClass().getMethod("upToDate");
                    upToDate.invoke(state);
                } catch (NoSuchMethodException e) {
                    // since Gradle 3.2 we need to do this
                    Method setDidWork = state.getClass().getMethod(
                            "setDidWork", boolean.class);
                    setDidWork.invoke(state, false);
                }
            }
        } catch (Exception e) {
            //just ignore
        }
    }
869889
private void setRemoteControlClientPlaybackState(int state) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            mRemoteControlClientCompat.setPlaybackState(state);
        }
    }
405800
private void setState(State state) {
    if (this.state != state) {
      this.state = state;
      LOGGER.debug("State changed: {}", state);
      changeListeners.forEach(l -> l.accept(state));
    }
  }
562126
synchronized void statusUpdate(TaskStatus status) {
    setProgress(status.getProgress());
    this.runState = status.getRunState();
    this.stateString = status.getStateString();
    this.nextRecordRange = status.getNextRecordRange();

    setDiagnosticInfo(status.getDiagnosticInfo());
    
    if (status.getStartTime() > 0) {
      this.startTime = status.getStartTime(); 
    }
    if (status.getFinishTime() > 0) {
      setFinishTime(status.getFinishTime()); 
    }
    
    this.phase = status.getPhase();
    this.counters = status.getCounters();
    this.outputSize = status.outputSize;
  }
1147597
public void enqueue(BaseDownloadTask task) {
        final DownloadTaskAdapter downloadTaskAdapter = (DownloadTaskAdapter) task;
        downloadTaskAdapter.assembleDownloadTask();
        FileDownloadList.getImpl().addIndependentTask(downloadTaskAdapter);
        serialQueue.enqueue(downloadTaskAdapter.getDownloadTask());
        listenerManager.addAutoRemoveListenersWhenTaskEnd(downloadTaskAdapter.getId());
        listenerManager.attachListener(downloadTaskAdapter.getDownloadTask(),
                downloadTaskAdapter.getCompatListener());
    }
23080
private void updateStreamState(StreamState state) {
        this.state = state;
        if (StreamState.CLOSED.equals(state)) {
            setCloseTime(System.currentTimeMillis());
            muxLink.closeStream(this);
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "current stream state for stream " + this.myID + " : " + this.state);
        }
    }
97186
function softwareUpdate_download(channel, waitForFinish, timeout) {
    waitForFinish = waitForFinish ? waitForFinish : true;

    // Check that the correct channel has been set
    this._controller.assert(function() {
      return channel == this.channel;
    }, "The current update channel is identical to the specified one.", this);

    // Click the next button
    var next = this.getElement({type: "button", subtype: "next"});
    this._controller.click(next);

    // Wait for the download page - if it fails the update was already cached
    try {
      this.waitForWizardPage(WIZARD_PAGES.downloading);

      if (waitForFinish)
        this.waitforDownloadFinished(timeout);
    } catch (ex) {
      this.waitForWizardPage(WIZARD_PAGES.finished);
    }
  }
691314
public void download() throws IOException, InterruptedException {
    if (!Files.exists(destinationFile.getParent())) {
      Files.createDirectories(destinationFile.getParent());
    }

    if (Files.exists(destinationFile)) {
      throw new FileAlreadyExistsException(destinationFile.toString());
    }
    URLConnection connection = address.openConnection();
    connection.setRequestProperty("User-Agent", userAgentString);

    try (InputStream in = connection.getInputStream()) {
      // note : contentLength can potentially be -1 if it is unknown.
      long contentLength = connection.getContentLengthLong();

      logger.info("Downloading " + address + " to " + destinationFile);

      try (BufferedOutputStream out =
          new BufferedOutputStream(
              Files.newOutputStream(destinationFile, StandardOpenOption.CREATE_NEW))) {

        progressListener.start(
            getDownloadStatus(contentLength, Locale.getDefault()), contentLength);

        int bytesRead;
        byte[] buffer = new byte[BUFFER_SIZE];

        while ((bytesRead = in.read(buffer)) != -1) {
          if (Thread.currentThread().isInterrupted()) {
            logger.warning("Download was interrupted\n");
            cleanUp();
            throw new InterruptedException("Download was interrupted");
          }

          out.write(buffer, 0, bytesRead);
          progressListener.update(bytesRead);
        }
      }
    }
    progressListener.done();
  }