我一直试图在Javascript中找出回调函数功能一段时间没有任何成功.我可能有代码乱了,但我没有得到任何Javascript错误,所以我认为语法有点正确.
基本上,我正在寻找getDistanceWithLatLong()函数在updateDB()开始之前结束,然后确保在printList()函数开始之前结束.
我让它在函数上使用硬编码的"setTimeout"调用,但是我过度补偿并迫使用户等待更长时间而不需要Callback的东西.
有什么建议?以下是代码:
function runSearchInOrder(callback) {
getDistanceWithLatLong(function() {
updateDB(function() {
printList(callback);
});
});
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试更新进度对话框以增加1-100%的内容.但是,没有任何增加.它总是只说0.虽然,我能够看到我的Log Cat中的数字打印出来,一切都在100之后结束.
有谁看到我错过了什么?在此先感谢您的任何帮助.
private class DownLoadSigTask extends AsyncTask<String, Integer, String> {
private final ProgressDialog dialog = new ProgressDialog(NasStorageNasList.this);
// Set the fileName and filesize to be used later
String fileName = (String) recordItem.get(mPresentDown).get("name");
String filesize = (String) recordItem.get(mPresentDown).get("filesize");
// can use UI thread here
@Override
protected void onPreExecute() {
this.dialog.setMessage("Downloading " + fileName + " from the server. Please wait.");
this.dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
this.dialog.setCancelable(false);
this.dialog.setCanceledOnTouchOutside(false);
this.dialog.show();
}
// automatically done on worker thread (separate from UI thread)
@Override
protected String doInBackground(final String... …Run Code Online (Sandbox Code Playgroud)