From fd51fad73b09922e80271ee429214109b6e035a0 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 31 Mar 2016 21:44:58 +0200 Subject: [PATCH] keep the core Downloader classes pure Java for easy testing --- .../main/java/org/fdroid/fdroid/net/Downloader.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/net/Downloader.java b/app/src/main/java/org/fdroid/fdroid/net/Downloader.java index 45ba5b884..f3ed8e207 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/Downloader.java +++ b/app/src/main/java/org/fdroid/fdroid/net/Downloader.java @@ -1,7 +1,5 @@ package org.fdroid.fdroid.net; -import android.support.annotation.NonNull; - import org.fdroid.fdroid.Utils; import java.io.File; @@ -32,6 +30,11 @@ public abstract class Downloader { protected final URL sourceUrl; protected String cacheTag; + /** + * This is meant only to send progress to {@link DownloaderService}. This + * also keeps this class pure Java so that it can be tested on the JVM, + * without requiring an Android device or emulator. + */ interface DownloaderProgressListener { void sendProgress(URL sourceUrl, int bytesRead, int totalBytes); } @@ -213,12 +216,12 @@ public abstract class Downloader { } @Override - public int read(@NonNull byte[] buffer) throws IOException { + public int read(byte[] buffer) throws IOException { return toWrap.read(buffer); } @Override - public int read(@NonNull byte[] buffer, int byteOffset, int byteCount) throws IOException { + public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException { return toWrap.read(buffer, byteOffset, byteCount); }