这是主要的。按钮-
public void onClick(View v) {
dialog.show();
getTheMarkerId();
markerisfalseortrue(0);
dialog.hide();
cdd.dismiss();
}
});
这是第一个任务:getTheMarkerId()
queryfindmarkerid.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> parseObjects, ParseException e) {
for (int i = 0; i<parseObjects.size(); i++)
{
if (parseObjects.get(i).getInt("longit") == themarkerlongitude && parseObjects.get(i).getInt("latit") == themarkerlatitude)
{
themarkerid = parseObjects.get(i).getObjectId();
}
}
}
});
这是第二个任务-markerisfalseortrue(int i)
if (i == 0)
{
queryfindmarkerid.getInBackground( themarkerid, new GetCallback<ParseObject>() {
public void done(ParseObject gameScore, ParseException e) {
if (e == null) {
nowscore = gameScore.getInt("false");
gameScore.put("false", nowscore +1 );
gameScore.saveInBackground();
}
}
});
问题是:此查询具有出色的网络连接。您必须等待,直到完成。我怎样才能等到触发任务完成。
将方法调用markerisfalseortrue(0);
放在getTheMarkerId()方法的done方法内部。这样,在第一个网络调用完成之前,markerisfalseortrue()方法将不会运行。
这是记住使用Parse查询方法及其回调的一种常见模式-如果您需要发出第二个请求,或执行某些只能在第一个网络调用完成后才能完成的操作,请在完成以下操作的方法中激活该操作:第一次网络通话。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句