1414import butterknife .ButterKnife ;
1515import butterknife .InjectView ;
1616import butterknife .OnClick ;
17- import com .morihacky .android .rxjava .R ;
1817import java .util .ArrayList ;
1918import java .util .List ;
2019import rx .Observable ;
2120import rx .Observer ;
22- import rx .Subscriber ;
2321import rx .Subscription ;
2422import rx .android .app .AppObservable ;
2523import rx .android .schedulers .AndroidSchedulers ;
24+ import rx .functions .Func1 ;
2625import rx .schedulers .Schedulers ;
2726import timber .log .Timber ;
2827
@@ -72,23 +71,17 @@ public void startLongOperation() {
7271 }
7372
7473 private Observable <Boolean > _getObservable () {
75- return Observable .create (new Observable .OnSubscribe <Boolean >() {
76-
74+ return Observable .just (true ).map (new Func1 <Boolean , Boolean >() {
7775 @ Override
78- public void call (Subscriber <? super Boolean > observer ) {
79-
80- _log ("Within Observable" );
81-
76+ public Boolean call (Boolean aBoolean ) {
8277 _doSomeLongOperation_thatBlocksCurrentThread ();
83- observer .onNext (true );
84- observer .onCompleted ();
78+ return aBoolean ;
8579 }
8680 });
8781 }
8882
8983 /**
90- * Observer that handles the result List<Integer> from Observable
91- * through the 3 important actions:
84+ * Observer that handles the result through the 3 important actions:
9285 *
9386 * 1. onCompleted
9487 * 2. onError
@@ -106,13 +99,13 @@ public void onCompleted() {
10699 @ Override
107100 public void onError (Throwable e ) {
108101 Timber .e (e , "Error in RxJava Demo concurrency" );
109- _log (String .format ("Boo Error %s" , e .getMessage ()));
102+ _log (String .format ("Boo! Error %s" , e .getMessage ()));
110103 _progress .setVisibility (View .INVISIBLE );
111104 }
112105
113106 @ Override
114- public void onNext (Boolean aBoolean ) {
115- _log (String .format ("onNext with return value \" %b\" " , aBoolean ));
107+ public void onNext (Boolean bool ) {
108+ _log (String .format ("onNext with return value \" %b\" " , bool ));
116109 }
117110 };
118111 }
0 commit comments