package com.novoda.downloadmanager;

class CallbackThrottleByProgressIncrease implements CallbackThrottle {

    private DownloadBatchStatusCallback callback;

    private int currentProgress;
    private DownloadBatchStatus.Status currentStatus;
    private DownloadError currentDownloadError;

    @Override
    public void setCallback(DownloadBatchStatusCallback callback) {
        this.callback = callback;
    }

    @Override
    public void update(DownloadBatchStatus currentDownloadBatchStatus) {
        if (callback == null) {
            return;
        }

        if (statusHasChanged(currentDownloadBatchStatus)
                || progressHasChanged(currentDownloadBatchStatus)
                || errorHasChanged(currentDownloadBatchStatus)) {

            currentStatus = currentDownloadBatchStatus.status();
            currentProgress = currentDownloadBatchStatus.percentageDownloaded();
            currentDownloadError = currentDownloadBatchStatus.downloadError();

            callback.onUpdate(currentDownloadBatchStatus);
        }
    }

    private boolean statusHasChanged(DownloadBatchStatus currentDownloadBatchStatus) {
        DownloadBatchStatus.Status newStatus = currentDownloadBatchStatus.status();
        return currentStatus != newStatus;
    }

    private boolean progressHasChanged(DownloadBatchStatus currentDownloadBatchStatus) {
        int newProgress = currentDownloadBatchStatus.percentageDownloaded();
        return currentProgress != newProgress;
    }

    private boolean errorHasChanged(DownloadBatchStatus currentDownloadBatchStatus) {
        DownloadError newDownloadError = currentDownloadBatchStatus.downloadError();
        return currentDownloadError != newDownloadError;
    }

    @Override
    public void stopUpdates() {
        callback = null;
    }
}

@@ -1236,24 +1236,25 @@
      return 
+!
 currentStatu
@@ -1254,20 +1254,24 @@
 ntStatus
- != 
+.equals(
 newStatu
@@ -1267,24 +1267,25 @@
 ls(newStatus
+)
 ;%0A    %7D%0A%0A   
@@ -1683,24 +1683,25 @@
      return 
+!
 currentDownl
@@ -1708,20 +1708,24 @@
 oadError
- != 
+.equals(
 newDownl
@@ -1732,16 +1732,17 @@
 oadError
+)
 ;%0A    %7D%0A

Use object equals.