use of com.example.jingbin.cloudreader.data.OnUserInfoListener 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.data.OnUserInfoListener in project CloudReader by youlookwhat.
the class CoinDetailFragment method initRefreshView.
private void initRefreshView() {
headerBinding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.header_coin_detail, (ViewGroup) bindingView.xrvWan.getParent(), false);
RefreshHelper.initLinear(bindingView.xrvWan, true, 1);
RefreshHelper.setSwipeRefreshView(bindingView.srlWan);
mAdapter = new CoinAdapter(activity, false);
bindingView.xrvWan.setAdapter(mAdapter);
bindingView.xrvWan.addHeaderView(headerBinding.getRoot());
headerBinding.tvHeaderCoin.setVisibility(View.INVISIBLE);
bindingView.srlWan.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
bindingView.xrvWan.postDelayed(new Runnable() {
@Override
public void run() {
viewModel.setPage(1);
getCoinLog();
}
}, 150);
}
});
bindingView.xrvWan.setOnLoadMoreListener(new ByRecyclerView.OnLoadMoreListener() {
@Override
public void onLoadMore() {
if (!bindingView.srlWan.isRefreshing()) {
int page = viewModel.getPage();
viewModel.setPage(++page);
getCoinLog();
} else {
bindingView.xrvWan.loadMoreComplete();
}
}
});
UserUtil.getUserInfo(new OnUserInfoListener() {
@Override
public void onSuccess(User user) {
if (user != null) {
headerBinding.tvHeaderCoin.setText(String.valueOf(user.getCoinCount()));
}
}
});
}
Aggregations