提交 33457774 authored 作者: 吴强's avatar 吴强
......@@ -80,6 +80,14 @@ public class Updater extends ReactContextBaseJavaModule {
WritableMap event;
do {
int numRead = is.read(buf);
if (numRead <= 0) {
event = Arguments.createMap();
event.putInt("progress", 100);
event.putInt("current", count);
event.putInt("all", length);
emit("Updater/downloaded", event);
break;
}
count += numRead;
int progress = (int) (((float) count / length) * 100);
if (progress != lastProgress) {
......@@ -90,14 +98,6 @@ public class Updater extends ReactContextBaseJavaModule {
event.putInt("all", length);
emit("Updater/downloading", event);
}
if (numRead <= 0) {
event = Arguments.createMap();
event.putInt("progress", progress);
event.putInt("current", count);
event.putInt("all", length);
emit("Updater/downloaded", event);
break;
}
fos.write(buf, 0, numRead);
} while (!cancel);
if (cancel) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论