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 — Merge pull request #17 from fabioCollini/master · devqmr/RxJava-Android-Samples@ba06507

File tree

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

‎app/src/main/java/com/morihacky/android/rxjava/RotationPersistFragment.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/RotationPersistFragment.java
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ public void onNext(Integer integer) {
108108
}
109109
}));
110110

111-
intsObservable.connect();
112111
}
113112

114113
// -----------------------------------------------------------------------------------
Collapse file

‎app/src/main/java/com/morihacky/android/rxjava/RotationPersistWorkerFragment.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/RotationPersistWorkerFragment.java
+11-2Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.List;
77
import java.util.concurrent.TimeUnit;
88
import rx.Observable;
9+
import rx.Subscription;
910
import rx.functions.Func1;
1011
import rx.observables.ConnectableObservable;
1112

@@ -14,6 +15,7 @@ public class RotationPersistWorkerFragment
1415

1516
private ConnectableObservable<Integer> storedIntsObservable;
1617
private IAmYourMaster _masterFrag;
18+
private Subscription storedIntsSubscription;
1719

1820
/**
1921
* Hold a reference to the activity -> caller fragment
@@ -66,6 +68,8 @@ public Integer call(Long aLong) {
6668
//_intsObservable = _intsObservable.share();
6769
storedIntsObservable = intsObservable.replay();
6870

71+
storedIntsSubscription = storedIntsObservable.connect();
72+
6973
// Do not do this in production!
7074
// `.share` is "warm" not "hot"
7175
// the below forceful subscription fakes the heat
@@ -76,8 +80,8 @@ public Integer call(Long aLong) {
7680
* The Worker fragment has started doing it's thing
7781
*/
7882
@Override
79-
public void onStart() {
80-
super.onStart();
83+
public void onResume() {
84+
super.onResume();
8185
_masterFrag.observeResults(storedIntsObservable);
8286
}
8387

@@ -91,6 +95,11 @@ public void onDetach() {
9195
_masterFrag = null;
9296
}
9397

98+
@Override public void onDestroy() {
99+
super.onDestroy();
100+
storedIntsSubscription.unsubscribe();
101+
}
102+
94103
public interface IAmYourMaster {
95104
void observeResults(ConnectableObservable<Integer> intsObservable);
96105
}

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.