keep the core Downloader classes pure Java for easy testing
This commit is contained in:
parent
514e83e604
commit
fd51fad73b
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user