purge urlString from ProgressListener, it is unused and confusing
This commit is contained in:
parent
6b0a784a26
commit
d794c5a77c
@ -70,7 +70,7 @@ public class HttpDownloaderTest {
|
||||
final HttpDownloader httpDownloader = new HttpDownloader(uri, destFile);
|
||||
httpDownloader.setListener(new ProgressListener() {
|
||||
@Override
|
||||
public void onProgress(String urlString, long bytesRead, long totalBytes) {
|
||||
public void onProgress(long bytesRead, long totalBytes) {
|
||||
receivedProgress = true;
|
||||
}
|
||||
});
|
||||
@ -132,7 +132,7 @@ public class HttpDownloaderTest {
|
||||
final HttpDownloader httpDownloader = new HttpDownloader(uri, destFile);
|
||||
httpDownloader.setListener(new ProgressListener() {
|
||||
@Override
|
||||
public void onProgress(String urlString, long bytesRead, long totalBytes) {
|
||||
public void onProgress(long bytesRead, long totalBytes) {
|
||||
receivedProgress = true;
|
||||
latch.countDown();
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ public class IndexUpdater {
|
||||
JarFile jarFile = new JarFile(downloadedFile, true);
|
||||
JarEntry indexEntry = (JarEntry) jarFile.getEntry(IndexUpdater.DATA_FILE_NAME);
|
||||
indexInputStream = new ProgressBufferedInputStream(jarFile.getInputStream(indexEntry),
|
||||
processIndexListener, repo.address, (int) indexEntry.getSize());
|
||||
processIndexListener, (int) indexEntry.getSize());
|
||||
|
||||
// Process the index...
|
||||
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||
@ -254,14 +254,14 @@ public class IndexUpdater {
|
||||
|
||||
protected final ProgressListener downloadListener = new ProgressListener() {
|
||||
@Override
|
||||
public void onProgress(String urlString, long bytesRead, long totalBytes) {
|
||||
public void onProgress(long bytesRead, long totalBytes) {
|
||||
UpdateService.reportDownloadProgress(context, IndexUpdater.this, bytesRead, totalBytes);
|
||||
}
|
||||
};
|
||||
|
||||
protected final ProgressListener processIndexListener = new ProgressListener() {
|
||||
@Override
|
||||
public void onProgress(String urlString, long bytesRead, long totalBytes) {
|
||||
public void onProgress(long bytesRead, long totalBytes) {
|
||||
UpdateService.reportProcessIndexProgress(context, IndexUpdater.this, bytesRead, totalBytes);
|
||||
}
|
||||
};
|
||||
|
@ -198,7 +198,7 @@ public class IndexV1Updater extends IndexUpdater {
|
||||
JarFile jarFile = new JarFile(outputFile, true);
|
||||
JarEntry indexEntry = (JarEntry) jarFile.getEntry(DATA_FILE_NAME);
|
||||
InputStream indexInputStream = new ProgressBufferedInputStream(jarFile.getInputStream(indexEntry),
|
||||
processIndexListener, repo.address, (int) indexEntry.getSize());
|
||||
processIndexListener, (int) indexEntry.getSize());
|
||||
processIndexV1(indexInputStream, indexEntry, cacheTag);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ import java.io.InputStream;
|
||||
class ProgressBufferedInputStream extends BufferedInputStream {
|
||||
|
||||
private final ProgressListener progressListener;
|
||||
private final String urlString;
|
||||
private final int totalBytes;
|
||||
|
||||
private int currentBytes;
|
||||
@ -18,10 +17,9 @@ class ProgressBufferedInputStream extends BufferedInputStream {
|
||||
* Reports progress to the specified {@link ProgressListener}, with the
|
||||
* progress based on the {@code totalBytes}.
|
||||
*/
|
||||
ProgressBufferedInputStream(InputStream in, ProgressListener progressListener, String urlString, int totalBytes) {
|
||||
ProgressBufferedInputStream(InputStream in, ProgressListener progressListener, int totalBytes) {
|
||||
super(in);
|
||||
this.progressListener = progressListener;
|
||||
this.urlString = urlString;
|
||||
this.totalBytes = totalBytes;
|
||||
}
|
||||
|
||||
@ -33,7 +31,7 @@ class ProgressBufferedInputStream extends BufferedInputStream {
|
||||
* the digits changing because it looks pretty, < 9000 since the reads won't
|
||||
* line up exactly */
|
||||
if (currentBytes % 333333 < 9000) {
|
||||
progressListener.onProgress(urlString, currentBytes, totalBytes);
|
||||
progressListener.onProgress(currentBytes, totalBytes);
|
||||
}
|
||||
}
|
||||
return super.read(buffer, byteOffset, byteCount);
|
||||
|
@ -19,6 +19,6 @@ import java.net.URL;
|
||||
*/
|
||||
public interface ProgressListener {
|
||||
|
||||
void onProgress(String urlString, long bytesRead, long totalBytes);
|
||||
void onProgress(long bytesRead, long totalBytes);
|
||||
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ public abstract class Downloader {
|
||||
@Override
|
||||
public void run() {
|
||||
if (downloaderProgressListener != null) {
|
||||
downloaderProgressListener.onProgress(urlString, bytesRead, totalBytes);
|
||||
downloaderProgressListener.onProgress(bytesRead, totalBytes);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -207,7 +207,7 @@ public class DownloaderService extends Service {
|
||||
downloader = DownloaderFactory.create(this, uri, localFile);
|
||||
downloader.setListener(new ProgressListener() {
|
||||
@Override
|
||||
public void onProgress(String urlString, long bytesRead, long totalBytes) {
|
||||
public void onProgress(long bytesRead, long totalBytes) {
|
||||
Intent intent = new Intent(Downloader.ACTION_PROGRESS);
|
||||
intent.setData(uri);
|
||||
intent.putExtra(Downloader.EXTRA_BYTES_READ, bytesRead);
|
||||
|
Loading…
x
Reference in New Issue
Block a user