Merge branch 'fix-download' into 'master'

fix download progress for large apps

Closes #1192

See merge request fdroid/fdroidclient!647
This commit is contained in:
Hans-Christoph Steiner 2018-03-06 14:04:54 +00:00
commit 7d45781611
2 changed files with 3 additions and 3 deletions

View File

@ -243,7 +243,7 @@ public class AppDetailsRecyclerViewAdapter
return new VersionsViewHolder(versionsView); return new VersionsViewHolder(versionsView);
} }
case VIEWTYPE_VERSION: case VIEWTYPE_VERSION:
View version = inflater.inflate(R.layout.apklistitem, parent, false); View version = inflater.inflate(R.layout.app_details2_version_item, parent, false);
return new VersionViewHolder(version); return new VersionViewHolder(version);
} }
return null; return null;
@ -387,12 +387,12 @@ public class AppDetailsRecyclerViewAdapter
progressLabel.setContentDescription(context.getString(R.string.downloading)); progressLabel.setContentDescription(context.getString(R.string.downloading));
progressPercent.setText(""); progressPercent.setText("");
} else if (totalBytes > 0 && bytesDownloaded >= 0) { } else if (totalBytes > 0 && bytesDownloaded >= 0) {
float percent = bytesDownloaded * 100 / totalBytes; float percent = (float) bytesDownloaded / totalBytes;
progressLabel.setText(Utils.getFriendlySize(bytesDownloaded) + " / " + Utils.getFriendlySize(totalBytes)); progressLabel.setText(Utils.getFriendlySize(bytesDownloaded) + " / " + Utils.getFriendlySize(totalBytes));
progressLabel.setContentDescription(context.getString(R.string.app__tts__downloading_progress, (int) percent)); progressLabel.setContentDescription(context.getString(R.string.app__tts__downloading_progress, (int) percent));
NumberFormat format = NumberFormat.getPercentInstance(); NumberFormat format = NumberFormat.getPercentInstance();
format.setMaximumFractionDigits(0); format.setMaximumFractionDigits(0);
progressPercent.setText(format.format(percent / 100)); progressPercent.setText(format.format(percent));
} else if (bytesDownloaded >= 0) { } else if (bytesDownloaded >= 0) {
progressLabel.setText(Utils.getFriendlySize(bytesDownloaded)); progressLabel.setText(Utils.getFriendlySize(bytesDownloaded));
progressLabel.setContentDescription(context.getString(R.string.downloading)); progressLabel.setContentDescription(context.getString(R.string.downloading));