-
-
Save emrekose26/8083221f13c20c984ef8cb75115effa9 to your computer and use it in GitHub Desktop.
Revisions
-
emrekose26 renamed this gist
Mar 14, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
emrekose26 revised this gist
Mar 14, 2017 . 3 changed files with 2 additions and 2 deletions.There are no files selected for viewing
File renamed without changes.This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; public class RxTransformer { /** * {@link rx.Observable.Transformer} that transforms the source observable to subscribe in the * io thread and observe on the Android's UI thread. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ApiService.getInstance().apiCall(parameter) .compose(RxTransformer.applyIOToMainThreadSchedulers()) .subscribe(data -> {});
-
lapastillaroja renamed this gist
Dec 3, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
lapastillaroja revised this gist
Dec 3, 2015 . 1 changed file with 17 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ Problem ``` Error:(29, 37) error: cannot find symbol method subscribeOn(Scheduler) ``` This happens compiling this code borrowed from http://blog.danlew.net/2015/03/02/dont-break-the-chain/#comment-2388677116 ```java final Observable.Transformer schedulersTransformer = observable -> observable.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); ``` Environment - Android Studio 2.0 - Retrolambda - Compiled with Java 8 -
lapastillaroja created this gist
Dec 2, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ import rx.Observable; import rx.Subscription; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; public class RxUtil { /** * {@link rx.Observable.Transformer} that transforms the source observable to subscribe in the * io thread and observe on the Android's UI thread. */ private static Observable.Transformer ioToMainThreadSchedulerTransformer; static { ioToMainThreadSchedulerTransformer = createIOToMainThreadScheduler(); } /** * Get {@link rx.Observable.Transformer} that transforms the source observable to subscribe in * the io thread and observe on the Android's UI thread. * * Because it doesn't interact with the emitted items it's safe ignore the unchecked casts. * * @return {@link rx.Observable.Transformer} */ @SuppressWarnings("unchecked") private static <T> Observable.Transformer<T, T> createIOToMainThreadScheduler() { return tObservable -> tObservable.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } @SuppressWarnings("unchecked") public static <T> Observable.Transformer<T, T> applyIOToMainThreadSchedulers() { return ioToMainThreadSchedulerTransformer; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ ApiService.getInstance().apiCall(parameter) .compose(RxUtil.applyIOToMainThreadSchedulers()) .subscribe(data -> {});