Closed Foamtor closed 6 years ago
使用异步的callAsync()
即可:
private void start() {
mDisposable = Observable.timer(400, TimeUnit.MILLISECONDS)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(aLong -> {
CC.obtainBuilder("component_login")
.setActionName("init").setNoTimeout().build().callAsync((cc, result) -> {
if (result.isSuccess()) {
toastMessage("登录成功");
CC.obtainBuilder("component_navigation").build().call();
} else {
toastMessage("登录失败");
}
});
});
}
有一点不是很理解,在CC框架实践(1):实现登录成功再进入目标界面功能中,
UserComponent的
onCall( )
方法里, 强制获取用户信息,若未登录则打开登录界面,在登录完成后再回调结果,异步实现
在OrderComponent中直接使用的call()
为什么不会出现超时?
为了防止ANR,在主线程同步调用( cc.call()
)时setNoTimeout()
是无效的
可以放在子线程执行.observeOn(Schedulers.io())
需求: 进入登录页面前,如果已经记住了密码,直接静默自动登录,否则进入到登录页面手动登录。 调用代码:
登录组件
call()
方法: