GeezerVison is showing github.com — fix: use unsubscriptions.clear instead of unsubscribe · MStart/RxJava-Android-Samples@1e7d4b2
File treeExpand 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 clipboard -9Lines changed: 0 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | package com.morihacky.android.rxjava; | 2 | 2 |
| 3 | 3 | import rx.Subscription; | 4 | | -import rx.subscriptions.CompositeSubscription; | 5 | 4 |
| 6 | 5 | public class RxUtils { | 7 | 6 |
| @@ -10,12 +9,4 @@ public static void unsubscribeIfNotNull(Subscription subscription) { | 10 | 9 | subscription.unsubscribe(); | 11 | 10 | } | 12 | 11 | } | 13 | | - | 14 | | - public static CompositeSubscription getNewCompositeSubIfUnsubscribed(CompositeSubscription subscription) { | 15 | | - if (subscription == null || subscription.isUnsubscribed()) { | 16 | | - return new CompositeSubscription(); | 17 | | - } | 18 | | - | 19 | | - return subscription; | 20 | | - } | 21 | 12 | } |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/fragments/BufferDemoFragment.java +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -53,8 +53,8 @@ public class BufferDemoFragment | 53 | 53 | private Subscription _subscription; | 54 | 54 |
| 55 | 55 | @Override | 56 | | - public void onStart() { | 57 | | - super.onStart(); | | 56 | + public void onResume() { | | 57 | + super.onResume(); | 58 | 58 | _subscription = _getBufferedSubscription(); | 59 | 59 | } | 60 | 60 |
| |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/fragments/ConcurrencyWithSchedulersDemoFragment.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,8 +42,8 @@ public class ConcurrencyWithSchedulersDemoFragment | 42 | 42 | @Override | 43 | 43 | public void onDestroy() { | 44 | 44 | super.onDestroy(); | 45 | | - RxUtils.unsubscribeIfNotNull(_subscription); | 46 | 45 | ButterKnife.unbind(this); | | 46 | + RxUtils.unsubscribeIfNotNull(_subscription); | 47 | 47 | } | 48 | 48 |
| 49 | 49 | @Override | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/fragments/DebounceSearchEmitterFragment.java +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 | import com.jakewharton.rxbinding.widget.RxTextView; | 16 | 16 | import com.jakewharton.rxbinding.widget.TextViewTextChangeEvent; | 17 | 17 | import com.morihacky.android.rxjava.R; | 18 | | -import com.morihacky.android.rxjava.RxUtils; | 19 | 18 |
| 20 | 19 | import java.util.ArrayList; | 21 | 20 | import java.util.List; | | 24 | 23 | import butterknife.Bind; | 25 | 24 | import butterknife.ButterKnife; | 26 | 25 | import butterknife.OnClick; | | 26 | +import co.kaush.core.util.CoreNullnessUtils; | 27 | 27 | import rx.Observer; | 28 | 28 | import rx.Subscription; | 29 | 29 | import rx.android.schedulers.AndroidSchedulers; | | 30 | +import rx.functions.Func1; | 30 | 31 | import timber.log.Timber; | 31 | 32 |
| 32 | 33 | import static java.lang.String.format; | @@ -45,7 +46,7 @@ public class DebounceSearchEmitterFragment | 45 | 46 | @Override | 46 | 47 | public void onDestroy() { | 47 | 48 | super.onDestroy(); | 48 | | - RxUtils.unsubscribeIfNotNull(_subscription); | | 49 | + _subscription.unsubscribe(); | 49 | 50 | ButterKnife.unbind(this); | 50 | 51 | } | 51 | 52 |
| |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/fragments/DoubleBindingTextViewFragment.java +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 | import android.widget.TextView; | 10 | 10 |
| 11 | 11 | import com.morihacky.android.rxjava.R; | 12 | | -import com.morihacky.android.rxjava.RxUtils; | 13 | 12 |
| 14 | 13 | import butterknife.Bind; | 15 | 14 | import butterknife.ButterKnife; | @@ -70,7 +69,7 @@ public void onNumberChanged() { | 70 | 69 | @Override | 71 | 70 | public void onDestroyView() { | 72 | 71 | super.onDestroyView(); | 73 | | - RxUtils.unsubscribeIfNotNull(_subscription); | | 72 | + _subscription.unsubscribe(); | 74 | 73 | ButterKnife.unbind(this); | 75 | 74 | } | 76 | 75 | } |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/fragments/ExponentialBackoffFragment.java +1-8Lines changed: 1 addition & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 | import android.widget.ListView; | 10 | 10 |
| 11 | 11 | import com.morihacky.android.rxjava.R; | 12 | | -import com.morihacky.android.rxjava.RxUtils; | 13 | 12 | import com.morihacky.android.rxjava.wiring.LogAdapter; | 14 | 13 |
| 15 | 14 | import java.util.ArrayList; | @@ -38,12 +37,6 @@ public class ExponentialBackoffFragment | 38 | 37 |
| 39 | 38 | private CompositeSubscription _subscriptions = new CompositeSubscription(); | 40 | 39 |
| 41 | | - @Override | 42 | | - public void onResume() { | 43 | | - super.onResume(); | 44 | | - _subscriptions = RxUtils.getNewCompositeSubIfUnsubscribed(_subscriptions); | 45 | | - } | 46 | | - | 47 | 40 | @Override | 48 | 41 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { | 49 | 42 | super.onActivityCreated(savedInstanceState); | @@ -63,7 +56,7 @@ public View onCreateView(LayoutInflater inflater, | 63 | 56 | public void onPause() { | 64 | 57 | super.onPause(); | 65 | 58 |
| 66 | | - RxUtils.unsubscribeIfNotNull(_subscriptions); | | 59 | + _subscriptions.clear(); | 67 | 60 | } | 68 | 61 |
| 69 | 62 | @Override | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/fragments/FormValidationCombineLatestFragment.java +1-7Lines changed: 1 addition & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 10 | 10 |
| 11 | 11 | import com.jakewharton.rxbinding.widget.RxTextView; | 12 | 12 | import com.morihacky.android.rxjava.R; | 13 | | -import com.morihacky.android.rxjava.RxUtils; | 14 | 13 |
| 15 | 14 | import butterknife.Bind; | 16 | 15 | import butterknife.ButterKnife; | @@ -55,16 +54,11 @@ public View onCreateView(LayoutInflater inflater, | 55 | 54 | return layout; | 56 | 55 | } | 57 | 56 |
| 58 | | - @Override | 59 | | - public void onPause() { | 60 | | - super.onPause(); | 61 | | - RxUtils.unsubscribeIfNotNull(_subscription); | 62 | | - } | 63 | | - | 64 | 57 | @Override | 65 | 58 | public void onDestroyView() { | 66 | 59 | super.onDestroyView(); | 67 | 60 | ButterKnife.unbind(this); | | 61 | + _subscription.unsubscribe(); | 68 | 62 | } | 69 | 63 |
| 70 | 64 | private void _combineLatestEvents() { | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/fragments/PollingFragment.java +11-3Lines changed: 11 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 12 | 12 | import android.widget.ListView; | 13 | 13 |
| 14 | 14 | import com.morihacky.android.rxjava.R; | 15 | | -import com.morihacky.android.rxjava.RxUtils; | 16 | 15 |
| 17 | 16 | import java.util.ArrayList; | 18 | 17 | import java.util.List; | @@ -40,9 +39,18 @@ public class PollingFragment | 40 | 39 |
| 41 | 40 | private LogAdapter _adapter; | 42 | 41 | private List<String> _logs; | 43 | | - private CompositeSubscription _subscriptions = new CompositeSubscription(); | | 42 | + | | 43 | + private CompositeSubscription _subscriptions; | 44 | 44 | private int _counter = 0; | 45 | 45 |
| | 46 | + | | 47 | + @Override | | 48 | + public void onCreate(@Nullable Bundle savedInstanceState) { | | 49 | + super.onCreate(savedInstanceState); | | 50 | + | | 51 | + _subscriptions = new CompositeSubscription(); | | 52 | + } | | 53 | + | 46 | 54 | @Override | 47 | 55 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { | 48 | 56 | super.onActivityCreated(savedInstanceState); | @@ -61,7 +69,7 @@ public View onCreateView(LayoutInflater inflater, | 61 | 69 | @Override | 62 | 70 | public void onDestroy() { | 63 | 71 | super.onDestroy(); | 64 | | - RxUtils.unsubscribeIfNotNull(_subscriptions); | | 72 | + _subscriptions.unsubscribe(); | 65 | 73 | ButterKnife.unbind(this); | 66 | 74 | } | 67 | 75 |
| |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/fragments/PseudoCacheConcatFragment.java -8Lines changed: 0 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 | import android.widget.ListView; | 10 | 10 |
| 11 | 11 | import com.morihacky.android.rxjava.R; | 12 | | -import com.morihacky.android.rxjava.RxUtils; | 13 | 12 | import com.morihacky.android.rxjava.retrofit.Contributor; | 14 | 13 | import com.morihacky.android.rxjava.retrofit.GithubApi; | 15 | 14 | import com.morihacky.android.rxjava.retrofit.GithubService; | @@ -33,7 +32,6 @@ public class PseudoCacheConcatFragment | 33 | 32 |
| 34 | 33 | @Bind(R.id.log_list) ListView _resultList; | 35 | 34 |
| 36 | | - private Subscription _subscription = null; | 37 | 35 | private HashMap<String, Long> _contributionMap = null; | 38 | 36 | private ArrayAdapter<String> _adapter; | 39 | 37 |
| @@ -47,12 +45,6 @@ public View onCreateView(LayoutInflater inflater, | 47 | 45 | return layout; | 48 | 46 | } | 49 | 47 |
| 50 | | - @Override | 51 | | - public void onPause() { | 52 | | - super.onPause(); | 53 | | - RxUtils.unsubscribeIfNotNull(_subscription); | 54 | | - } | 55 | | - | 56 | 48 | @Override | 57 | 49 | public void onDestroyView() { | 58 | 50 | super.onDestroyView(); | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/morihacky/android/rxjava/fragments/PseudoCacheMergeFragment.java +3-11Lines changed: 3 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 10 | 10 | import android.widget.ListView; | 11 | 11 |
| 12 | 12 | import com.morihacky.android.rxjava.R; | 13 | | -import com.morihacky.android.rxjava.RxUtils; | 14 | 13 | import com.morihacky.android.rxjava.retrofit.Contributor; | 15 | 14 | import com.morihacky.android.rxjava.retrofit.GithubApi; | 16 | 15 | import com.morihacky.android.rxjava.retrofit.GithubService; | | 24 | 23 | import butterknife.OnClick; | 25 | 24 | import rx.Observable; | 26 | 25 | import rx.Subscriber; | 27 | | -import rx.Subscription; | 28 | 26 | import rx.android.schedulers.AndroidSchedulers; | 29 | 27 | import rx.functions.Func1; | 30 | 28 | import rx.schedulers.Schedulers; | @@ -34,27 +32,21 @@ public class PseudoCacheMergeFragment | 34 | 32 | extends BaseFragment { | 35 | 33 |
| 36 | 34 | @Bind(R.id.log_list) ListView _resultList; | | 35 | + | 37 | 36 | private ArrayAdapter<String> _adapter; | 38 | 37 | private HashMap<String, Long> _contributionMap = null; | 39 | 38 | private HashMap<Contributor, Long> _resultAgeMap = new HashMap<>(); | 40 | | - private Subscription _subscription = null; | 41 | 39 |
| 42 | 40 | @Override | 43 | 41 | public View onCreateView(LayoutInflater inflater, | 44 | | - @Nullable ViewGroup container, | 45 | | - @Nullable Bundle savedInstanceState) { | | 42 | + @Nullable ViewGroup container, | | 43 | + @Nullable Bundle savedInstanceState) { | 46 | 44 | View layout = inflater.inflate(R.layout.fragment_pseudo_cache_concat, container, false); | 47 | 45 | ButterKnife.bind(this, layout); | 48 | 46 | _initializeCache(); | 49 | 47 | return layout; | 50 | 48 | } | 51 | 49 |
| 52 | | - @Override | 53 | | - public void onPause() { | 54 | | - super.onPause(); | 55 | | - RxUtils.unsubscribeIfNotNull(_subscription); | 56 | | - } | 57 | | - | 58 | 50 | @Override | 59 | 51 | public void onDestroyView() { | 60 | 52 | super.onDestroyView(); | |
|