keep the core Downloader classes pure Java for easy testing

This commit is contained in:
Hans-Christoph Steiner 2016-03-31 21:44:58 +02:00
parent 514e83e604
commit fd51fad73b

View File

@ -1,7 +1,5 @@
package org.fdroid.fdroid.net; package org.fdroid.fdroid.net;
import android.support.annotation.NonNull;
import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.Utils;
import java.io.File; import java.io.File;
@ -32,6 +30,11 @@ public abstract class Downloader {
protected final URL sourceUrl; protected final URL sourceUrl;
protected String cacheTag; 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 { interface DownloaderProgressListener {
void sendProgress(URL sourceUrl, int bytesRead, int totalBytes); void sendProgress(URL sourceUrl, int bytesRead, int totalBytes);
} }
@ -213,12 +216,12 @@ public abstract class Downloader {
} }
@Override @Override
public int read(@NonNull byte[] buffer) throws IOException { public int read(byte[] buffer) throws IOException {
return toWrap.read(buffer); return toWrap.read(buffer);
} }
@Override @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); return toWrap.read(buffer, byteOffset, byteCount);
} }