通知中心 - 仿iOS
- 基于EventBus
- 支持綁定對(duì)象
- 書(shū)寫(xiě)起來(lái)簡(jiǎn)便些篷牌,使用lamda表達(dá)式和塊代碼
附Demo
/// add observer for notification
private void addXCNotificationObservers() {
XCNotificationCenter.defaultCenter().add(
this,
XCNotificationName.name(XCNotificationConstant.kEvent1),
this,
(notification) -> {
System.out.println("received notification");
});
}
/// post notification
private void postXCNotification() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
XCNotificationCenter.defaultCenter().post(
XCNotificationName.name(XCNotificationConstant.kEvent1),
"aUserInfo",
MainActivity.this);
}
}, 8000);
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者