Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatmap 的用法的两个问题 #10

Open
ihrthk opened this issue May 27, 2016 · 0 comments
Open

Flatmap 的用法的两个问题 #10

ihrthk opened this issue May 27, 2016 · 0 comments

Comments

@ihrthk
Copy link

ihrthk commented May 27, 2016

subscription = fakeApi.getFakeToken("fake_auth_code")
                .flatMap(new Func1<FakeToken, Observable<FakeThing>>() { 
                    @Override 
                    public Observable<FakeThing> call(FakeToken fakeToken) { 
                        return fakeApi.getFakeData(fakeToken); 
                    } 
                }) 
                .subscribeOn(Schedulers.io()) 
                .observeOn(AndroidSchedulers.mainThread()) 
                .subscribe(new Action1<FakeThing>() { 
                    @Override 
                    public void call(FakeThing fakeData) {
//1.在这里怎么获取request httpurl
//List<Cookie> cookies = Cookie.parseAll(call.request().url(), response.headers());
//2.在这里怎么fakeToken数据,我要整合fakeToken和fakeData,一起返回
                        swipeRefreshLayout.setRefreshing(false);
                        tokenTv.setText(getString(R.string.got_data, fakeData.id, fakeData.name));
                    } 
                }, new Action1<Throwable>() {
                    @Override 
                    public void call(Throwable throwable) {
                        swipeRefreshLayout.setRefreshing(false);
                        Toast.makeText(getActivity(), R.string.loading_failed, Toast.LENGTH_SHORT).show();
                    } 
                }); 
    } 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant