@@ -44,10 +44,10 @@ public static <T> Observable<T> observeFromAndroidComponent(Observable<T> source
4444 }
4545
4646 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 ));
4848 }
4949
50- private static abstract class OnSubscribeBase <T , AndroidComponent > implements Observable .OnSubscribeFunc <T > {
50+ private static class OnSubscribeBase <T , AndroidComponent > implements Observable .OnSubscribeFunc <T > {
5151
5252 private static final String LOG_TAG = OperationObserveFromAndroidComponent .class .getSimpleName ();
5353
@@ -68,7 +68,9 @@ private void log(String message) {
6868 }
6969 }
7070
71- protected abstract boolean isComponentValid (AndroidComponent component );
71+ protected boolean isComponentValid (AndroidComponent component ) {
72+ return true ;
73+ }
7274
7375 @ Override
7476 public Subscription onSubscribe (Observer <? super T > observer ) {
@@ -148,18 +150,6 @@ protected boolean isComponentValid(android.support.v4.app.Fragment fragment) {
148150 }
149151 }
150152
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-
163153 @ RunWith (RobolectricTestRunner .class )
164154 @ Config (manifest = Config .NONE )
165155 public static final class UnitTest {
@@ -292,36 +282,6 @@ public void itDoesNotForwardOnErrorIfFragmentIsDetached() {
292282 verify (mockObserver , never ()).onError (any (Exception .class ));
293283 }
294284
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-
325285 @ Test
326286 public void itUnsubscribesFromTheSourceSequence () {
327287 Subscription underlying = mock (Subscription .class );
0 commit comments