-
Notifications
You must be signed in to change notification settings - Fork 23
/
ListPresenter.java
51 lines (37 loc) · 1.2 KB
/
ListPresenter.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
package com.kmangutov.restexample.presenters;
import com.kmangutov.restexample.models.Post;
import com.kmangutov.restexample.services.ForumService;
import com.kmangutov.restexample.views.ListActivity;
import java.util.List;
import rx.Observer;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
/**
* Created by kmangutov on 3/25/15.
*/
public class ListPresenter {
ListActivity mView;
ForumService mForum;
public ListPresenter(ListActivity view, ForumService forum) {
mView = view;
mForum = forum;
}
public void loadPosts() {
mForum.getApi()
.getPosts()
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<List<Post>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(List<Post> posts) {
mView.displayPosts(posts);
}
});
}
}