Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug #2

Open
xieguangwei opened this issue Aug 8, 2018 · 0 comments
Open

bug #2

xieguangwei opened this issue Aug 8, 2018 · 0 comments

Comments

@xieguangwei
Copy link

xieguangwei commented Aug 8, 2018

private final Handler mHandler = new Handler(Looper.getMainLooper()) {
@OverRide
public void handleMessage(Message msg) {
switch (msg.what) {
case APPLE_INFO:
Apple apple = (Apple) msg.obj;
//观察者模式,通知所有客户端
final int clientNum = mCallbacks.beginBroadcast();
for (int i = 0; i < clientNum; i++) {
IRemoteServiceCallBack callBack = mCallbacks.getBroadcastItem(i);
if (callBack != null && apple != null) {
try {
callBack.noticeAppleInfo(apple);
} catch (RemoteException e) {
e.printStackTrace();
}
}
mCallbacks.finishBroadcast();
}
break;
}
super.handleMessage(msg);
}
mCallbacks.finishBroadcast();应该放到for循环后面,不然通知一个就结束了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant