Android在服务

时间:2016-09-30 19:51:38

标签: android

以下代码在我的活动或片段上工作正常,但是当我旋转手机时,此方法再次起作用,如何将其移动到Ui上进行服务并获取事件?

private void getUserStories() {
    mSubscriptions.add(mDataManager.getUserPosts(mUser)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeOn(mDataManager.getScheduler())
            .subscribe(new Subscriber<Post>() {
                @Override
                public void onCompleted() { }

                @Override
                public void onError(Throwable e) {
                    hideLoadingViews();
                    Timber.e("There was a problem loading the user stories " + e);
                    DialogFactory.createSimpleOkErrorDialog(
                            getActivity(),
                            getString(R.string.error_stories)
                    ).show();
                }

                @Override
                public void onNext(Post story) {
                    hideLoadingViews();
                    mPostAdapter.addItem(story);
                }
            }));
}

0 个答案:

没有答案