Don't add count=-1 to bytesRead when finished

This commit is contained in:
Daniel Martí 2015-05-30 00:51:35 +02:00
parent 29403c1d84
commit 38ab8ac353

View File

@ -173,12 +173,12 @@ public abstract class Downloader {
int count = input.read(buffer); int count = input.read(buffer);
throwExceptionIfInterrupted(); throwExceptionIfInterrupted();
bytesRead += count;
sendProgress(bytesRead, totalBytes);
if (count == -1) { if (count == -1) {
Log.d(TAG, "Finished downloading from stream"); Log.d(TAG, "Finished downloading from stream");
break; break;
} }
bytesRead += count;
sendProgress(bytesRead, totalBytes);
outputStream.write(buffer, 0, count); outputStream.write(buffer, 0, count);
} }
outputStream.flush(); outputStream.flush();