File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
app/src/main/java/com/morihacky/android/rxjava Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,36 @@ public void onNext(Long number) {
106106 });
107107 }
108108
109+ @ OnClick (R .id .btn_demo_timing_3 )
110+ public void Btn3_RunTask_IntervalOf1s_StartImmediately () {
111+ if (_subscription2 != null && !_subscription2 .isUnsubscribed ()) {
112+ _subscription2 .unsubscribe ();
113+ _log (String .format ("C3 [%s] XXX BTN KILLED" , _getCurrentTimestamp ()));
114+ return ;
115+ }
116+
117+ _log (String .format ("C3 [%s] --- BTN click" , _getCurrentTimestamp ()));
118+
119+ _subscription2 = Observable //
120+ .timer (0 , 1 , TimeUnit .SECONDS )//
121+ .subscribe (new Observer <Long >() {
122+ @ Override
123+ public void onCompleted () {
124+ _log (String .format ("C3 [%s] XXXX COMPLETE" , _getCurrentTimestamp ()));
125+ }
126+
127+ @ Override
128+ public void onError (Throwable e ) {
129+ Timber .e (e , "something went wrong in TimingDemoFragment example" );
130+ }
131+
132+ @ Override
133+ public void onNext (Long number ) {
134+ _log (String .format ("C3 [%s] NEXT" , _getCurrentTimestamp ()));
135+ }
136+ });
137+ }
138+
109139 @ OnClick (R .id .btn_demo_timing_4 )
110140 public void Btn4_RunTask5Times_IntervalOf3s () {
111141 _log (String .format ("D4 [%s] --- BTN click" , _getCurrentTimestamp ()));
You can’t perform that action at this time.
0 commit comments