diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java index a017983f0..85271a083 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java @@ -53,8 +53,7 @@ public class DownloadLogAdapter extends BaseAdapter { holder.date = (TextView) convertView.findViewById(R.id.txtvDate); holder.title = (TextView) convertView.findViewById(R.id.txtvTitle); holder.type = (TextView) convertView.findViewById(R.id.txtvType); - holder.reason = (TextView) convertView - .findViewById(R.id.txtvReason); + holder.reason = (TextView) convertView.findViewById(R.id.txtvReason); convertView.setTag(holder); } else { holder = (Holder) convertView.getTag(); diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java index f79cf9685..0faa3f7c1 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java @@ -219,21 +219,18 @@ public class HttpDownloader extends Downloader { long freeSpace = StorageUtils.getFreeSpaceAvailable(); Log.d(TAG, "Free space is " + freeSpace); - if (request.getSize() != DownloadStatus.SIZE_UNKNOWN - && request.getSize() > freeSpace) { + if (request.getSize() != DownloadStatus.SIZE_UNKNOWN && request.getSize() > freeSpace) { onFail(DownloadError.ERROR_NOT_ENOUGH_SPACE, null); return; } Log.d(TAG, "Starting download"); try { - while (!cancelled - && (count = connection.read(buffer)) != -1) { + while (!cancelled && (count = connection.read(buffer)) != -1) { out.write(buffer, 0, count); request.setSoFar(request.getSoFar() + count); - request.setProgressPercent((int) (((double) request - .getSoFar() / (double) request - .getSize()) * 100)); + int progressPercent = (int)(100.0 * request.getSoFar() / request.getSize()); + request.setProgressPercent(progressPercent); } } catch(IOException e) { Log.e(TAG, Log.getStackTraceString(e)); @@ -245,12 +242,8 @@ public class HttpDownloader extends Downloader { // written file. This check cannot be made if compression was used if (!isGzip && request.getSize() != DownloadStatus.SIZE_UNKNOWN && request.getSoFar() != request.getSize()) { - onFail(DownloadError.ERROR_IO_ERROR, - "Download completed but size: " + - request.getSoFar() + - " does not equal expected size " + - request.getSize() - ); + onFail(DownloadError.ERROR_IO_ERROR, "Download completed but size: " + + request.getSoFar() + " does not equal expected size " + request.getSize()); return; } else if(request.getSize() > 0 && request.getSoFar() == 0){ onFail(DownloadError.ERROR_IO_ERROR, "Download completed, but nothing was read"); @@ -294,7 +287,8 @@ public class HttpDownloader extends Downloader { } private void onFail(DownloadError reason, String reasonDetailed) { - Log.d(TAG, "Download failed"); + Log.d(TAG, "onFail() called with: " + "reason = [" + reason + "], " + + "reasonDetailed = [" + reasonDetailed + "]"); result.setFailed(reason, reasonDetailed); if (request.isDeleteOnFailure()) { cleanup();