提交 55bf05a9 authored 作者: 吴强's avatar 吴强
...@@ -73,9 +73,15 @@ public class Updater extends ReactContextBaseJavaModule { ...@@ -73,9 +73,15 @@ public class Updater extends ReactContextBaseJavaModule {
int numRead = is.read(buf); int numRead = is.read(buf);
count += numRead; count += numRead;
int progress = (int) (((float) count / length) * 100); int progress = (int) (((float) count / length) * 100);
cb.invoke("downloading", progress, count, length); if (cb != null) {
Log.i("Updater", cb.toString());
cb.invoke("downloading", progress, count, length);
}
if (numRead <= 0) { if (numRead <= 0) {
cb.invoke("downloaded", progress, count, length); if (cb != null) {
Log.i("Updater", cb.toString());
cb.invoke("downloaded", progress, count, length);
}
break; break;
} }
fos.write(buf, 0, numRead); fos.write(buf, 0, numRead);
...@@ -117,7 +123,7 @@ public class Updater extends ReactContextBaseJavaModule { ...@@ -117,7 +123,7 @@ public class Updater extends ReactContextBaseJavaModule {
} }
} }
} }
}); }).start();
} else { } else {
promise.reject("ERROR_UPDATE", "There is another updater worker running already."); promise.reject("ERROR_UPDATE", "There is another updater worker running already.");
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论