X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/35b25f04ebb3c8ef78349c18b98e98ac6257a6ea..fb8194b7ebcc386a6749bf81ec498445ef851f13:/src/com/owncloud/android/files/services/FileDownloader.java diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index 7872c367..5fd6665a 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -49,6 +49,7 @@ import android.os.Looper; import android.os.Message; import android.os.Process; import android.util.Log; +import android.widget.ProgressBar; import android.widget.RemoteViews; import com.owncloud.android.R; @@ -214,6 +215,55 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis } } } + + + /** + * Adds a listener interested in the progress of the download for a concrete file. + * + * @param listener Object to notify about progress of transfer. + * @param account ownCloud account holding the file of interest. + * @param file {@link OCfile} of interest for listener. + */ + public void addDatatransferProgressListener (OnDatatransferProgressListener listener, Account account, OCFile file) { + if (account == null || file == null) return; + String targetKey = buildRemoteName(account, file); + DownloadFileOperation target = null; + synchronized (mPendingDownloads) { + if (!file.isDirectory()) { + target = mPendingDownloads.get(targetKey); + } else { + // nothing to do for directories, right now + } + } + if (target != null) { + target.addDatatransferProgressListener(listener); + } + } + + + /** + * Removes a listener interested in the progress of the download for a concrete file. + * + * @param listener Object to notify about progress of transfer. + * @param account ownCloud account holding the file of interest. + * @param file {@link OCfile} of interest for listener. + */ + public void removeDatatransferProgressListener (OnDatatransferProgressListener listener, Account account, OCFile file) { + if (account == null || file == null) return; + String targetKey = buildRemoteName(account, file); + DownloadFileOperation target = null; + synchronized (mPendingDownloads) { + if (!file.isDirectory()) { + target = mPendingDownloads.get(targetKey); + } else { + // nothing to do for directories, right now + } + } + if (target != null) { + target.removeDatatransferProgressListener(listener); + } + } + }