我在代码中的两个地方使用了处理程序。我的代码如下:
public void onClick(View v) {
vibrator.vibrate(Constants.DEFAULT_VIBRATE_TIME);
checkPassword();
List<NameValuePair> userDetails = new ArrayList<NameValuePair>();
Utils.addCustomerLoginDetail(userDetails);
final ProgressDialog progress = ProgressDialog.show(
ChangePasswordActivity.this, "", "Saving Please wait..");
Ola.asyncHttpClient.get(HttpCommunicator.getFilledUrl(
UrlConstants.AUTH_SEND_LOGIN_INFO_URL, userDetails),
new AsyncHttpResponseHandler() {
public void onSuccess(String arg0) {
serverResponse = arg0;
handler.post(new Runnable() {
@Override
public void run() {
verifyLoginDetails();
}
});
};
@Override
public void onFinish() {
if(isRunning())
progress.dismiss();
};
});
if (!doValidations()
|| !isConnectedToInternet()) {
return;
}
updateCustomerDetails();
List<NameValuePair> list = new ArrayList<NameValuePair>();
Utils.addUserId(list);
Utils.addCustomerPassword(list);
final ProgressDialog progressDialog = ProgressDialog.show(
ChangePasswordActivity.this, "", "Saving Please wait..");
Ola.asyncHttpClient.get(HttpCommunicator.getFilledUrl(
UrlConstants.AUTH_UPDATE_PROFILE_URL, list),
new AsyncHttpResponseHandler() {
public void onSuccess(String arg0) {
serverResponse = arg0;
handler.post(new Runnable() {
@Override
public void run() {
sendCustomerDetailsToServer();
}
});
};
public void onFailure(Throwable arg0, String arg1) {
showOlaDialog(Ola.NO_CONNECTIVITY);
};
@Override
public void onFinish() {
if(isRunning())
progressDialog.dismiss();
};
});
}
};
我面临的问题是代码的第二部分(if 语句之后的部分)被执行并在第一部分之前完成。
我需要做些什么来确保第一部分在第二部分开始之前完成。