[英]how to execute original method after callback finished?
there are some problem when I develop my code.当我开发我的代码时有一些问题。 for ex)例如)
a.java一个.java
public OnResultCallbackListener(){
part C
}
protected void onCreate(){
(skipped)
button.setOnClickListener(){
method a(arg0, arg1, arg2, ...., OnResultCallbackListener);
--------------------------------
part B
--------------------------------
}
}
I want to execute in this order.我想按这个顺序执行。 when I click button, method a executed.当我单击按钮时,方法 a 执行。 And method A will call callback(OnResultCallbackListener) and when OnResultCallbackListener finished(part C), code below method a executed(part B)方法A将调用回调(OnResultCallbackListener),当OnResultCallbackListener完成(C部分)时,方法a下面的代码已执行(B部分)
so, the order is method A - OnResultCallbackListener (part C) - part B. but my code executes part B first.因此,顺序是方法 A - OnResultCallbackListener(C 部分)- B 部分。但我的代码首先执行 B 部分。 OnResultCallbackListener needs server connection, so I cannot modify it. OnResultCallbackListener 需要服务器连接,所以我无法修改它。
in this situation, How can I execute my code in the way that I want?在这种情况下,我如何以我想要的方式执行我的代码?
Wrapper the callback listener with a compound listener.使用复合侦听器包装回调侦听器。
public OnResultCallbackListener(){
// part C
}
public CompoundCallbackListener(){
OnResultCallbackListener();
// part B
}
protected void onCreate() {
// (skipped)
button.setOnClickListener(){
method a(arg0, arg1, arg2, ...., CompoundCallbackListener);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.