-
Notifications
You must be signed in to change notification settings - Fork 0
/
CJPresenter.java
82 lines (65 loc) · 2.66 KB
/
CJPresenter.java
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.sola.github.dagger2demo.presenter;
import com.sola.github.dagger2demo.ui.params.UserInfoViewDTO;
import com.sola.github.domain.cases.AUserCenterCase;
import com.sola.github.domain.exception.ErrorDTO;
import com.sola.github.domain.params.params.uc.UserInfoDTO;
import com.sola.github.tools.delegate.IRecyclerViewDelegate;
import java.util.Collection;
import java.util.LinkedList;
import javax.inject.Inject;
import rx.functions.Action1;
/**
* Created by Sola
* 2017/2/22.
*/
@SuppressWarnings("unused")
public class CJPresenter {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
private final AUserCenterCase userCenterCase;
// ===========================================================
// Constructors
// ===========================================================
@Inject
CJPresenter(
AUserCenterCase userCenterCase) {
this.userCenterCase = userCenterCase;
}
// ===========================================================
// Getter & Setter
// ===========================================================
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
// ===========================================================
// Methods
// ===========================================================
public void requestUserInfo(
String userId,
Action1<IRecyclerViewDelegate> onNext,
Action1<ErrorDTO> onError) {
userCenterCase.requestUserInfo(userId,
userInfoDTO -> onNext.call(new UserInfoViewDTO(userInfoDTO)),
onError);
}
public void requestUserList(
Action1<Collection<IRecyclerViewDelegate>> onNext,
Action1<ErrorDTO> onError) {
userCenterCase.requestUserList(userInfoDTOs -> onNext.call(transform(userInfoDTOs)), onError);
}
private Collection<IRecyclerViewDelegate> transform(Collection<UserInfoDTO> userInfoDTOs) {
Collection<IRecyclerViewDelegate> retList = new LinkedList<>();
for (UserInfoDTO user :
userInfoDTOs) {
retList.add(new UserInfoViewDTO(user));
}
return retList;
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}