@@ -44,10 +44,10 @@ public static <T> Observable<T> observeFromAndroidComponent(Observable<T> source
44
44
}
45
45
46
46
public static <T > Observable <T > observeFromAndroidComponent (Observable <T > source , Activity activity ) {
47
- return Observable .create (new OnSubscribeActivity < T >(source , activity ));
47
+ return Observable .create (new OnSubscribeBase < T , Activity >(source , activity ));
48
48
}
49
49
50
- private static abstract class OnSubscribeBase <T , AndroidComponent > implements Observable .OnSubscribeFunc <T > {
50
+ private static class OnSubscribeBase <T , AndroidComponent > implements Observable .OnSubscribeFunc <T > {
51
51
52
52
private static final String LOG_TAG = OperationObserveFromAndroidComponent .class .getSimpleName ();
53
53
@@ -68,7 +68,9 @@ private void log(String message) {
68
68
}
69
69
}
70
70
71
- protected abstract boolean isComponentValid (AndroidComponent component );
71
+ protected boolean isComponentValid (AndroidComponent component ) {
72
+ return true ;
73
+ }
72
74
73
75
@ Override
74
76
public Subscription onSubscribe (Observer <? super T > observer ) {
@@ -148,18 +150,6 @@ protected boolean isComponentValid(android.support.v4.app.Fragment fragment) {
148
150
}
149
151
}
150
152
151
- private static final class OnSubscribeActivity <T > extends OnSubscribeBase <T , Activity > {
152
-
153
- private OnSubscribeActivity (Observable <T > source , Activity activity ) {
154
- super (source , activity );
155
- }
156
-
157
- @ Override
158
- protected boolean isComponentValid (Activity activity ) {
159
- return !activity .isFinishing ();
160
- }
161
- }
162
-
163
153
@ RunWith (RobolectricTestRunner .class )
164
154
@ Config (manifest = Config .NONE )
165
155
public static final class UnitTest {
@@ -292,36 +282,6 @@ public void itDoesNotForwardOnErrorIfFragmentIsDetached() {
292
282
verify (mockObserver , never ()).onError (any (Exception .class ));
293
283
}
294
284
295
- @ Test
296
- public void isDoesNotForwardOnNextOnCompletedSequenceIfActivityIsFinishing () {
297
- PublishSubject <Integer > source = PublishSubject .create ();
298
- OperationObserveFromAndroidComponent .observeFromAndroidComponent (source , mockActivity ).subscribe (mockObserver );
299
-
300
- source .onNext (1 );
301
-
302
- when (mockActivity .isFinishing ()).thenReturn (true );
303
- source .onNext (2 );
304
- source .onNext (3 );
305
- source .onCompleted ();
306
-
307
- verify (mockObserver ).onNext (1 );
308
- verify (mockObserver , never ()).onCompleted ();
309
- }
310
-
311
- @ Test
312
- public void itDoesNotForwardOnErrorIfActivityIsFinishing () {
313
- PublishSubject <Integer > source = PublishSubject .create ();
314
- OperationObserveFromAndroidComponent .observeFromAndroidComponent (source , mockActivity ).subscribe (mockObserver );
315
-
316
- source .onNext (1 );
317
-
318
- when (mockActivity .isFinishing ()).thenReturn (true );
319
- source .onError (new Exception ());
320
-
321
- verify (mockObserver ).onNext (1 );
322
- verify (mockObserver , never ()).onError (any (Exception .class ));
323
- }
324
-
325
285
@ Test
326
286
public void itUnsubscribesFromTheSourceSequence () {
327
287
Subscription underlying = mock (Subscription .class );
0 commit comments