show number of mb in download

This commit is contained in:
Ben Fry
2022-11-25 17:45:36 -05:00
parent 6e78e9aa5c
commit 587361dd40
2 changed files with 15 additions and 3 deletions
+14 -2
View File
@@ -856,11 +856,23 @@ public class JavaEditor extends Editor {
conn.setRequestMethod("GET");
conn.connect();
int length = conn.getContentLength();
// float size = (length >> 10) / 1024f;
//float size = (length / 1000) / 1000f;
// String msg =
// "Downloading reference (" + PApplet.nf(size, 0, 1) + " MB)… ";
String mb = PApplet.nf((length >> 10) / 1024f, 0, 1);
if (mb.endsWith(".0")) {
mb = mb.substring(0, mb.length() - 2); // don't show .0
}
ProgressMonitorInputStream input =
new ProgressMonitorInputStream(this,
"Downloading reference", conn.getInputStream());
input.getProgressMonitor().setMaximum(conn.getContentLength());
"Downloading reference (" + mb + " MB)… ", conn.getInputStream());
input.getProgressMonitor().setMaximum(length);
// ProgressMonitor monitor = input.getProgressMonitor();
// monitor.setMaximum(length);
PApplet.saveStream(getOfflineReferenceFile(), input);
// reset the internal handling for the reference server
useReferenceServer = null;
} catch (InterruptedIOException iioe) {
+1 -1
View File
@@ -11,7 +11,7 @@ _ https://github.com/processing/processing4/wiki/Translations
_ https://www.oracle.com/java/technologies/javase/jdk17-suported-locales.html
X implement offline reference download
X https://github.com/processing/processing-website/releases/download/2022-10-05-1459/reference.zip
_ add a note about the file size to the progress window
X add a note about the file size to the progress window
_ document and grab other notes from elsewhere here