AccountBalancePresenter.java
2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.dayu.bigfish.presenter.accountbalance;
import android.content.Intent;
import android.databinding.ObservableField;
import com.app.annotation.apt.InstanceFactory;
import com.apt.ApiFactory;
import com.dayu.bigfish.Constants;
import com.dayu.bigfish.base.BasePageBean;
import com.dayu.bigfish.bean.AccountBalance;
import com.dayu.bigfish.bean.UserInfo;
import com.dayu.bigfish.ui.WithdrawalsActivity;
import com.dayu.bigfish.utils.managers.UserManager;
import io.reactivex.functions.Consumer;
/**
* Created by luofan on 2017/11/14.
*/
@InstanceFactory
public class AccountBalancePresenter extends AccountBalanceContract.Presenter {
public ObservableField<String> totalPrice = new ObservableField<>();
public ObservableField datas = new ObservableField();
private int mAccoutId;
private int mPage;
@Override
public void onAttached() {
String price = "¥" + mActivity.getIntent().getIntExtra(Constants.ACCOUNT_BALANCE, 0);
totalPrice.set(price);
UserInfo userInfo = UserManager.getInstance().getUser();
mAccoutId = Integer.parseInt(userInfo.getAccountId());
refresh();
}
@Override
public void refresh() {
mPage = 1;
getAccountBalanceList(mPage, Constants.PAGESIZE, mAccoutId);
}
@Override
public void loadMore() {
getAccountBalanceList(mPage, Constants.PAGESIZE, mAccoutId);
}
@Override
public ObservableField<Object> getSourceDatas() {
return datas;
}
@Override
public void getAccountBalanceList(int page, int pageSize, int accountId) {
ApiFactory.getAccountBalanceList(page, pageSize, accountId).subscribe(baseObserver(new Consumer<BasePageBean<AccountBalance>>() {
@Override
public void accept(BasePageBean<AccountBalance> accountBalanceBasePageBean) throws Exception {
datas.set(accountBalanceBasePageBean);
mPage++;
}
}, throwable -> datas.set(Constants.FAILED)));
}
@Override
public void dumpToWithdrawal() {
Intent intent = new Intent(mActivity, WithdrawalsActivity.class);
mActivity.startActivity(intent);
}
}