RxJava defer -> fromCallable

This commit is contained in:
Martin Fietz 2015-11-26 16:29:20 +01:00
parent 6bf4d28c34
commit cc00d03bf0
10 changed files with 10 additions and 10 deletions

View File

@ -772,7 +772,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
private DBReader.NavDrawerData navDrawerData;
private void loadData() {
subscription = Observable.defer(() -> Observable.just(DBReader.getNavDrawerData()))
subscription = Observable.fromCallable(() -> DBReader.getNavDrawerData())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {

View File

@ -636,7 +636,7 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity
};
private void loadData() {
subscription = Observable.defer(() -> Observable.just(DBReader.getNavDrawerData()))
subscription = Observable.fromCallable(() -> DBReader.getNavDrawerData())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {

View File

@ -116,7 +116,7 @@ public class OnlineFeedViewActivity extends ActionBarActivity {
@Override
public void update(EventDistributor eventDistributor, Integer arg) {
if ((arg & EventDistributor.FEED_LIST_UPDATE) != 0) {
updater = Observable.defer(() -> Observable.just(DBReader.getFeedList()))
updater = Observable.fromCallable(() -> DBReader.getFeedList())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(feeds -> {

View File

@ -427,7 +427,7 @@ public class AllEpisodesFragment extends Fragment {
recyclerView.setVisibility(View.GONE);
progLoading.setVisibility(View.VISIBLE);
}
subscription = Observable.defer(() -> Observable.just(loadData()))
subscription = Observable.fromCallable(() -> loadData())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(data -> {

View File

@ -156,7 +156,7 @@ public class CompletedDownloadsFragment extends ListFragment {
if (!itemsLoaded && viewCreated) {
setListShown(false);
}
subscription = Observable.defer(() -> Observable.just(DBReader.getDownloadedItems()))
subscription = Observable.fromCallable(() -> DBReader.getDownloadedItems())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {

View File

@ -147,7 +147,7 @@ public class DownloadLogFragment extends ListFragment {
if(subscription != null) {
subscription.unsubscribe();
}
subscription = Observable.defer(() -> Observable.just(DBReader.getDownloadLog()))
subscription = Observable.fromCallable(() -> DBReader.getDownloadLog())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {

View File

@ -520,7 +520,7 @@ public class ItemFragment extends Fragment {
if(subscription != null) {
subscription.unsubscribe();
}
subscription = Observable.defer(() -> Observable.just(loadInBackground()))
subscription = Observable.fromCallable(() -> loadInBackground())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {

View File

@ -627,7 +627,7 @@ public class ItemlistFragment extends ListFragment {
subscription.unsubscribe();
}
subscription = Observable.defer(() -> Observable.just(loadData()))
subscription = Observable.fromCallable(() -> loadData())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {

View File

@ -252,7 +252,7 @@ public class PlaybackHistoryFragment extends ListFragment {
if(subscription != null) {
subscription.unsubscribe();
}
subscription = Observable.defer(() -> Observable.just(loadData()))
subscription = Observable.fromCallable(() -> loadData())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {

View File

@ -204,7 +204,7 @@ public class SearchFragment extends ListFragment {
if (viewCreated && !itemsLoaded) {
setListShown(false);
}
subscription = Observable.defer(() -> Observable.just(performSearch()))
subscription = Observable.fromCallable(() -> performSearch())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {