|
23 | 23 | import butterknife.Bind; |
24 | 24 | import butterknife.ButterKnife; |
25 | 25 | import butterknife.OnClick; |
26 | | -import rx.Observer; |
27 | | -import rx.Subscription; |
28 | | -import rx.android.schedulers.AndroidSchedulers; |
| 26 | +import hu.akarnokd.rxjava.interop.RxJavaInterop; |
| 27 | +import io.reactivex.android.schedulers.AndroidSchedulers; |
| 28 | +import io.reactivex.disposables.Disposable; |
| 29 | +import io.reactivex.observers.DisposableObserver; |
29 | 30 | import timber.log.Timber; |
30 | 31 |
|
31 | 32 | import static co.kaush.core.util.CoreNullnessUtils.isNotNullOrEmpty; |
@@ -40,12 +41,12 @@ public class DebounceSearchEmitterFragment |
40 | 41 | private LogAdapter _adapter; |
41 | 42 | private List<String> _logs; |
42 | 43 |
|
43 | | - private Subscription _subscription; |
| 44 | + private Disposable _disposable; |
44 | 45 |
|
45 | 46 | @Override |
46 | 47 | public void onDestroy() { |
47 | 48 | super.onDestroy(); |
48 | | - _subscription.unsubscribe(); |
| 49 | + _disposable.dispose(); |
49 | 50 | ButterKnife.unbind(this); |
50 | 51 | } |
51 | 52 |
|
@@ -70,20 +71,20 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { |
70 | 71 | super.onActivityCreated(savedInstanceState); |
71 | 72 | _setupLogger(); |
72 | 73 |
|
73 | | - _subscription = RxTextView.textChangeEvents(_inputSearchText) |
| 74 | + _disposable = RxJavaInterop.toV2Observable(RxTextView.textChangeEvents(_inputSearchText)) |
74 | 75 | .debounce(400, TimeUnit.MILLISECONDS)// default Scheduler is Computation |
75 | 76 | .filter(changes -> isNotNullOrEmpty(_inputSearchText.getText().toString())) |
76 | 77 | .observeOn(AndroidSchedulers.mainThread()) |
77 | | - .subscribe(_getSearchObserver()); |
| 78 | + .subscribeWith(_getSearchObserver()); |
78 | 79 | } |
79 | 80 |
|
80 | 81 | // ----------------------------------------------------------------------------------- |
81 | 82 | // Main Rx entities |
82 | 83 |
|
83 | | - private Observer<TextViewTextChangeEvent> _getSearchObserver() { |
84 | | - return new Observer<TextViewTextChangeEvent>() { |
| 84 | + private DisposableObserver<TextViewTextChangeEvent> _getSearchObserver() { |
| 85 | + return new DisposableObserver<TextViewTextChangeEvent>() { |
85 | 86 | @Override |
86 | | - public void onCompleted() { |
| 87 | + public void onComplete() { |
87 | 88 | Timber.d("--------- onComplete"); |
88 | 89 | } |
89 | 90 |
|
|