GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: assign subscription from AndroidObservable · linked-k/Android-RxJava@7aba299

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • app/src/main/java/com/morihacky/android/rxjava/rxbus
    • RxBusFrag2.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎app/src/main/java/com/morihacky/android/rxjava/rxbus/RxBusFrag2.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/rxbus/RxBusFrag2.java
+17-10Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@
1212
import butterknife.InjectView;
1313
import com.morihacky.android.rxjava.MainActivity;
1414
import com.morihacky.android.rxjava.app.R;
15+
import java.util.concurrent.TimeUnit;
1516
import rx.Subscription;
1617
import rx.android.observables.AndroidObservable;
1718
import rx.functions.Action1;
19+
import rx.schedulers.Schedulers;
1820

1921
import static com.morihacky.android.rxjava.rxbus.RxBusFrag1.TapEvent;
2022

2123
public class RxBusFrag2
2224
extends Fragment {
2325

2426
private RxBus _rxBus;
25-
private Subscription _subscription;
27+
private Subscription _subscription1_tapListen;
2628

2729
@InjectView(R.id.demo_rxbus_tap_txt) TextView _tapEventTxtShow;
2830

@@ -44,14 +46,19 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
4446
@Override
4547
public void onStart() {
4648
super.onStart();
47-
AndroidObservable.bindFragment(this, _rxBus.toObserverable()).subscribe(new Action1<Object>() {
48-
@Override
49-
public void call(Object event) {
50-
if (event instanceof TapEvent) {
51-
_showTapText();
52-
}
53-
}
54-
});
49+
50+
_subscription1_tapListen = AndroidObservable.bindFragment(this, _rxBus.toObserverable())
51+
.subscribe(new Action1<Object>() {
52+
@Override
53+
public void call(Object event) {
54+
if (event instanceof TapEvent) {
55+
_showTapText();
56+
}
57+
}
58+
});
59+
60+
_rxBus.toObserverable().debounce(400, TimeUnit.MILLISECONDS, Schedulers.io()).subscribe();
61+
5562
}
5663

5764
private void _showTapText() {
@@ -63,6 +70,6 @@ private void _showTapText() {
6370
@Override
6471
public void onStop() {
6572
super.onStop();
66-
_subscription.unsubscribe();
73+
_subscription1_tapListen.unsubscribe();
6774
}
6875
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.