GeezerVison is showing github.com — feat: add button 3 example where you start immediately and then go on… · klmpois/Android-RxJava@4feeb5f
File tree
Expand file treeCollapse file tree
Open diff view settings
app/src/main/java/com/morihacky/android/rxjava
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/TimingDemoFragment.java +30Lines changed: 30 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -106,6 +106,36 @@ public void onNext(Long number) { |
106 | 106 | }); |
107 | 107 | } |
108 | 108 |
|
| 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 | + |
109 | 139 | @OnClick(R.id.btn_demo_timing_4) |
110 | 140 | public void Btn4_RunTask5Times_IntervalOf3s() { |
111 | 141 | _log(String.format("D4 [%s] --- BTN click", _getCurrentTimestamp())); |
|