use of com.example.jingbin.cloudreader.bean.wanandroid.CoinUserInfoBean in project CloudReader by youlookwhat.
the class MainViewModel method getUserInfo.
public void getUserInfo() {
UserUtil.getUserInfo(new OnUserInfoListener() {
@Override
public void onSuccess(User user) {
if (user != null) {
execute(HttpClient.Builder.getWanAndroidServer().getCoinUserInfo(), new Observer<BaseResultBean<CoinUserInfoBean>>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable(d);
}
@Override
public void onNext(BaseResultBean<CoinUserInfoBean> bean) {
if (bean != null && bean.getData() != null) {
CoinUserInfoBean infoBean = bean.getData();
infoBean.setUsername(user.getUsername());
coin.setValue(infoBean);
UserUtil.getUserInfo(new OnUserInfoListener() {
@Override
public void onSuccess(User user) {
if (user != null) {
user.setCoinCount(infoBean.getCoinCount());
user.setRank(infoBean.getRank());
UserUtil.setUserInfo(user);
}
}
});
}
}
@Override
public void onError(Throwable e) {
coin.setValue(null);
}
@Override
public void onComplete() {
}
});
} else {
coin.setValue(null);
}
}
});
}
use of com.example.jingbin.cloudreader.bean.wanandroid.CoinUserInfoBean in project CloudReader by youlookwhat.
the class MainActivity method initDrawerLayout.
/**
* inflateHeaderView 进来的布局要宽一些
*/
private void initDrawerLayout() {
bindingView.navView.inflateHeaderView(R.layout.nav_header_main);
View headerView = bindingView.navView.getHeaderView(0);
bind = DataBindingUtil.bind(headerView);
bind.setViewModel(viewModel);
viewModel.isReadOk.set(SPUtils.isRead());
viewModel.isReadOkNight.set(SPUtils.isReadNight());
GlideUtil.displayCircle(bind.ivAvatar, ConstantsImageUrl.IC_AVATAR);
bind.llNavExit.setOnClickListener(this);
bind.ivAvatar.setOnClickListener(this);
bind.llNavHomepage.setOnClickListener(listener);
bind.llNavScanDownload.setOnClickListener(listener);
bind.llNavDeedback.setOnClickListener(listener);
bind.llNavAbout.setOnClickListener(listener);
bind.llNavLogin.setOnClickListener(listener);
bind.llNavCollect.setOnClickListener(listener);
bind.llNavShare.setOnClickListener(listener);
bind.llInfo.setOnClickListener(listener);
bind.llNavCoin.setOnClickListener(listener);
bind.llNavAdmire.setOnClickListener(listener);
bind.tvRank.setOnClickListener(listener);
bind.llNavNightMode.setOnClickListener(listener);
viewModel.getUserInfo();
viewModel.coin.observe(this, new Observer<CoinUserInfoBean>() {
@Override
public void onChanged(@Nullable CoinUserInfoBean coinUserInfoBean) {
if (coinUserInfoBean != null) {
bind.tvUsername.setText(coinUserInfoBean.getUsername());
bind.tvLevel.setText(String.format("Lv.%s", UserUtil.getLevel(coinUserInfoBean.getCoinCount())));
bind.tvRank.setText(String.format("排名 %s", coinUserInfoBean.getRank()));
} else {
bind.tvUsername.setText("玩安卓登录");
bind.tvLevel.setText("Lv.1");
bind.tvRank.setText("");
}
}
});
}
Aggregations