From 601e9d13d4dba28f126dc294b3ad604a17c26817 Mon Sep 17 00:00:00 2001 From: Hajime Morrita Date: Wed, 26 Nov 2014 13:15:12 -0800 Subject: [PATCH] Move Activity and Fragment related operations to rx.android.app This aligns the package name of Android framework classes. --- .../java/rx/android/app/AppObservable.java | 109 ++++++++++++ .../OperatorConditionalBinding.java | 6 +- .../rx/android/content/ContentObservable.java | 100 ++--------- .../java/rx/android/view/ViewObservable.java | 2 +- .../rx/android/app/AppObservableTest.java | 156 ++++++++++++++++++ .../OperatorConditionalBindingTest.java | 8 +- .../content/ContentObservableTest.java | 129 --------------- .../android/samples/ListFragmentActivity.java | 6 +- .../android/samples/ListenInOutActivity.java | 2 +- .../samples/ListeningFragmentActivity.java | 4 +- .../samples/RetainedFragmentActivity.java | 2 +- 11 files changed, 293 insertions(+), 231 deletions(-) create mode 100644 rxandroid/src/main/java/rx/android/app/AppObservable.java rename rxandroid/src/main/java/rx/android/{content => app}/OperatorConditionalBinding.java (98%) create mode 100644 rxandroid/src/test/java/rx/android/app/AppObservableTest.java rename rxandroid/src/test/java/rx/android/{content => app}/OperatorConditionalBindingTest.java (97%) diff --git a/rxandroid/src/main/java/rx/android/app/AppObservable.java b/rxandroid/src/main/java/rx/android/app/AppObservable.java new file mode 100644 index 00000000..c2e70395 --- /dev/null +++ b/rxandroid/src/main/java/rx/android/app/AppObservable.java @@ -0,0 +1,109 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.android.app; + +import android.app.Activity; +import android.app.Fragment; +import android.os.Build; + +import rx.Observable; +import rx.android.internal.Assertions; +import rx.functions.Func1; + +import static rx.android.schedulers.AndroidSchedulers.mainThread; + +public final class AppObservable { + private AppObservable() { + throw new AssertionError("No instances"); + } + + static { + boolean supportFragmentsAvailable = false; + try { + Class.forName("android.support.v4.app.Fragment"); + supportFragmentsAvailable = true; + } catch (ClassNotFoundException e) { + } + + USES_SUPPORT_FRAGMENTS = supportFragmentsAvailable; + } + + private static final Func1 ACTIVITY_VALIDATOR = new Func1() { + @Override + public Boolean call(Activity activity) { + return !activity.isFinishing(); + } + }; + private static final Func1 FRAGMENT_VALIDATOR = new Func1() { + @Override + public Boolean call(Fragment fragment) { + return fragment.isAdded() && !fragment.getActivity().isFinishing(); + } + }; + private static final Func1 FRAGMENTV4_VALIDATOR = + new Func1() { + @Override + public Boolean call(android.support.v4.app.Fragment fragment) { + return fragment.isAdded() && !fragment.getActivity().isFinishing(); + } + }; + public static final boolean USES_SUPPORT_FRAGMENTS; + + /** + * Binds the given source sequence to an activity. + *

+ * This helper will schedule the given sequence to be observed on the main UI thread and ensure + * that no notifications will be forwarded to the activity in case it is scheduled to finish. + *

+ * You should unsubscribe from the returned Observable in onDestroy at the latest, in order to not + * leak the activity or an inner subscriber. Conversely, when the source sequence can outlive the activity, + * make sure to bind to new instances of the activity again, e.g. after going through configuration changes. + * Refer to the samples project for actual examples. + * + * @param activity the activity to bind the source sequence to + * @param source the source sequence + */ + public static Observable bindActivity(Activity activity, Observable source) { + Assertions.assertUiThread(); + return source.observeOn(mainThread()).lift(new OperatorConditionalBinding(activity, ACTIVITY_VALIDATOR)); + } + + /** + * Binds the given source sequence to a fragment (native or support-v4). + *

+ * This helper will schedule the given sequence to be observed on the main UI thread and ensure + * that no notifications will be forwarded to the fragment in case it gets detached from its + * activity or the activity is scheduled to finish. + *

+ * You should unsubscribe from the returned Observable in onDestroy for normal fragments, or in onDestroyView + * for retained fragments, in order to not leak any references to the host activity or the fragment. + * Refer to the samples project for actual examples. + * + * @param fragment the fragment to bind the source sequence to + * @param source the source sequence + */ + public static Observable bindFragment(Object fragment, Observable source) { + Assertions.assertUiThread(); + final Observable o = source.observeOn(mainThread()); + if (USES_SUPPORT_FRAGMENTS && fragment instanceof android.support.v4.app.Fragment) { + android.support.v4.app.Fragment f = (android.support.v4.app.Fragment) fragment; + return o.lift(new OperatorConditionalBinding(f, FRAGMENTV4_VALIDATOR)); + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && fragment instanceof Fragment) { + Fragment f = (Fragment) fragment; + return o.lift(new OperatorConditionalBinding(f, FRAGMENT_VALIDATOR)); + } else { + throw new IllegalArgumentException("Target fragment is neither a native nor support library Fragment"); + } + } +} diff --git a/rxandroid/src/main/java/rx/android/content/OperatorConditionalBinding.java b/rxandroid/src/main/java/rx/android/app/OperatorConditionalBinding.java similarity index 98% rename from rxandroid/src/main/java/rx/android/content/OperatorConditionalBinding.java rename to rxandroid/src/main/java/rx/android/app/OperatorConditionalBinding.java index 0e619210..008cb20b 100644 --- a/rxandroid/src/main/java/rx/android/content/OperatorConditionalBinding.java +++ b/rxandroid/src/main/java/rx/android/app/OperatorConditionalBinding.java @@ -2,16 +2,16 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -package rx.android.content; +package rx.android.app; import rx.Observable; import rx.Subscriber; diff --git a/rxandroid/src/main/java/rx/android/content/ContentObservable.java b/rxandroid/src/main/java/rx/android/content/ContentObservable.java index 4a6910ad..68987cd5 100644 --- a/rxandroid/src/main/java/rx/android/content/ContentObservable.java +++ b/rxandroid/src/main/java/rx/android/content/ContentObservable.java @@ -1,106 +1,32 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package rx.android.content; -import android.app.Activity; -import android.app.Fragment; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.database.Cursor; -import android.os.Build; import android.os.Handler; import rx.Observable; -import rx.android.internal.Assertions; -import rx.functions.Func1; - -import static rx.android.schedulers.AndroidSchedulers.mainThread; public final class ContentObservable { private ContentObservable() { throw new AssertionError("No instances"); } - private static final Func1 ACTIVITY_VALIDATOR = new Func1() { - @Override - public Boolean call(Activity activity) { - return !activity.isFinishing(); - } - }; - private static final Func1 FRAGMENT_VALIDATOR = new Func1() { - @Override - public Boolean call(Fragment fragment) { - return fragment.isAdded() && !fragment.getActivity().isFinishing(); - } - }; - private static final Func1 FRAGMENTV4_VALIDATOR = - new Func1() { - @Override - public Boolean call(android.support.v4.app.Fragment fragment) { - return fragment.isAdded() && !fragment.getActivity().isFinishing(); - } - }; - - private static final boolean USES_SUPPORT_FRAGMENTS; - - static { - boolean supportFragmentsAvailable = false; - try { - Class.forName("android.support.v4.app.Fragment"); - supportFragmentsAvailable = true; - } catch (ClassNotFoundException e) { - } - - USES_SUPPORT_FRAGMENTS = supportFragmentsAvailable; - } - - /** - * Binds the given source sequence to an activity. - *

- * This helper will schedule the given sequence to be observed on the main UI thread and ensure - * that no notifications will be forwarded to the activity in case it is scheduled to finish. - *

- * You should unsubscribe from the returned Observable in onDestroy at the latest, in order to not - * leak the activity or an inner subscriber. Conversely, when the source sequence can outlive the activity, - * make sure to bind to new instances of the activity again, e.g. after going through configuration changes. - * Refer to the samples project for actual examples. - * - * @param activity the activity to bind the source sequence to - * @param source the source sequence - */ - public static Observable bindActivity(Activity activity, Observable source) { - Assertions.assertUiThread(); - return source.observeOn(mainThread()).lift(new OperatorConditionalBinding(activity, ACTIVITY_VALIDATOR)); - } - - /** - * Binds the given source sequence to a fragment (native or support-v4). - *

- * This helper will schedule the given sequence to be observed on the main UI thread and ensure - * that no notifications will be forwarded to the fragment in case it gets detached from its - * activity or the activity is scheduled to finish. - *

- * You should unsubscribe from the returned Observable in onDestroy for normal fragments, or in onDestroyView - * for retained fragments, in order to not leak any references to the host activity or the fragment. - * Refer to the samples project for actual examples. - * - * @param fragment the fragment to bind the source sequence to - * @param source the source sequence - */ - public static Observable bindFragment(Object fragment, Observable source) { - Assertions.assertUiThread(); - final Observable o = source.observeOn(mainThread()); - if (USES_SUPPORT_FRAGMENTS && fragment instanceof android.support.v4.app.Fragment) { - android.support.v4.app.Fragment f = (android.support.v4.app.Fragment) fragment; - return o.lift(new OperatorConditionalBinding(f, FRAGMENTV4_VALIDATOR)); - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && fragment instanceof Fragment) { - Fragment f = (Fragment) fragment; - return o.lift(new OperatorConditionalBinding(f, FRAGMENT_VALIDATOR)); - } else { - throw new IllegalArgumentException("Target fragment is neither a native nor support library Fragment"); - } - } - /** * Create Observable that wraps BroadcastReceiver and emmit received intents. * diff --git a/rxandroid/src/main/java/rx/android/view/ViewObservable.java b/rxandroid/src/main/java/rx/android/view/ViewObservable.java index 93f8ff36..19fb8629 100644 --- a/rxandroid/src/main/java/rx/android/view/ViewObservable.java +++ b/rxandroid/src/main/java/rx/android/view/ViewObservable.java @@ -39,7 +39,7 @@ public static Observable clicks(final View view, final boolean emi * This helper will schedule the given sequence to be observed on the main UI thread and ensure * that no notifications will be forwarded to the view in case it gets detached from its the window. *

- * Unlike {@link rx.android.content.ContentObservable#bindActivity} or {@link rx.android.content.ContentObservable#bindFragment}, you don't have to unsubscribe the returned {@code Observable} + * Unlike {@link rx.android.app.AppObservable#bindActivity} or {@link rx.android.app.AppObservable#bindFragment}, you don't have to unsubscribe the returned {@code Observable} * on the detachment. {@link #bindView} does it automatically. * That means that the subscriber doesn't see further sequence even if the view is recycled and * attached again. diff --git a/rxandroid/src/test/java/rx/android/app/AppObservableTest.java b/rxandroid/src/test/java/rx/android/app/AppObservableTest.java new file mode 100644 index 00000000..e6bc548c --- /dev/null +++ b/rxandroid/src/test/java/rx/android/app/AppObservableTest.java @@ -0,0 +1,156 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.android.app; + + +import android.app.Activity; +import android.app.Fragment; +import android.support.v4.app.FragmentActivity; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.robolectric.Robolectric; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; + +import java.util.concurrent.Callable; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; + +import rx.Observable; +import rx.Observer; +import rx.android.TestUtil; +import rx.observers.TestObserver; + +import static org.mockito.Mockito.verify; + +@RunWith(RobolectricTestRunner.class) +@Config(manifest = Config.NONE) +public class AppObservableTest { + // support library fragments + private FragmentActivity fragmentActivity; + private android.support.v4.app.Fragment supportFragment; + + // native fragments + private Activity activity; + private Fragment fragment; + + @Mock + private Observer observer; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + supportFragment = new android.support.v4.app.Fragment(); + fragmentActivity = Robolectric.buildActivity(FragmentActivity.class).create().get(); + fragmentActivity.getSupportFragmentManager().beginTransaction().add(supportFragment, null).commit(); + + fragment = new Fragment(); + activity = Robolectric.buildActivity(Activity.class).create().get(); + activity.getFragmentManager().beginTransaction().add(fragment, null).commit(); + } + + @Test + public void itSupportsFragmentsFromTheSupportV4Library() { + AppObservable.bindFragment(supportFragment, Observable.just("success")).subscribe(new TestObserver(observer)); + verify(observer).onNext("success"); + verify(observer).onCompleted(); + } + + @Test + public void itSupportsNativeFragments() { + AppObservable.bindFragment(fragment, Observable.just("success")).subscribe(new TestObserver(observer)); + verify(observer).onNext("success"); + verify(observer).onCompleted(); + } + + @Test(expected = IllegalArgumentException.class) + public void itThrowsIfObjectPassedIsNotAFragment() { + AppObservable.bindFragment("not a fragment", Observable.never()); + } + + @Test(expected = IllegalStateException.class) + public void itThrowsIfObserverCallsFromFragmentFromBackgroundThread() throws Throwable { + final Future future = Executors.newSingleThreadExecutor().submit(new Callable() { + @Override + public Object call() throws Exception { + AppObservable.bindFragment(fragment, Observable.empty()); + return null; + } + }); + try { + future.get(1, TimeUnit.SECONDS); + } catch (ExecutionException e) { + throw e.getCause(); + } + } + + @Test + public void bindFragmentToSourceFromDifferentThread() throws InterruptedException { + CountDownLatch done = new CountDownLatch(1); + AppObservable.bindFragment(fragment, TestUtil.atBackgroundThread(done)).subscribe(new TestObserver(observer)); + done.await(); + + Robolectric.runUiThreadTasksIncludingDelayedTasks(); + + verify(observer).onNext(TestUtil.STRING_EXPECTATION); + verify(observer).onCompleted(); + } + + @Test + public void bindSupportFragmentToSourceFromDifferentThread() throws InterruptedException { + CountDownLatch done = new CountDownLatch(1); + AppObservable.bindFragment(supportFragment, TestUtil.atBackgroundThread(done)).subscribe(new TestObserver(observer)); + done.await(); + + Robolectric.runUiThreadTasksIncludingDelayedTasks(); + + verify(observer).onNext(TestUtil.STRING_EXPECTATION); + verify(observer).onCompleted(); + } + + @Test(expected = IllegalStateException.class) + public void itThrowsIfObserverCallsFromActivityFromBackgroundThread() throws Throwable { + final Future future = Executors.newSingleThreadExecutor().submit(new Callable() { + @Override + public Object call() throws Exception { + AppObservable.bindActivity(activity, Observable.empty()); + return null; + } + }); + try { + future.get(1, TimeUnit.SECONDS); + } catch (ExecutionException e) { + throw e.getCause(); + } + } + + @Test + public void bindActivityToSourceFromDifferentThread() throws InterruptedException { + CountDownLatch done = new CountDownLatch(1); + AppObservable.bindActivity(activity, TestUtil.atBackgroundThread(done)).subscribe(new TestObserver(observer)); + done.await(); + + Robolectric.runUiThreadTasksIncludingDelayedTasks(); + + verify(observer).onNext(TestUtil.STRING_EXPECTATION); + verify(observer).onCompleted(); + } +} diff --git a/rxandroid/src/test/java/rx/android/content/OperatorConditionalBindingTest.java b/rxandroid/src/test/java/rx/android/app/OperatorConditionalBindingTest.java similarity index 97% rename from rxandroid/src/test/java/rx/android/content/OperatorConditionalBindingTest.java rename to rxandroid/src/test/java/rx/android/app/OperatorConditionalBindingTest.java index 2ab27b9b..57a546e5 100644 --- a/rxandroid/src/test/java/rx/android/content/OperatorConditionalBindingTest.java +++ b/rxandroid/src/test/java/rx/android/app/OperatorConditionalBindingTest.java @@ -2,16 +2,16 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -package rx.android.content; +package rx.android.app; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -22,7 +22,7 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import rx.Subscriber; -import rx.android.content.OperatorConditionalBinding; +import rx.android.app.OperatorConditionalBinding; import rx.functions.Func1; import rx.internal.util.UtilityFunctions; import rx.observers.TestSubscriber; diff --git a/rxandroid/src/test/java/rx/android/content/ContentObservableTest.java b/rxandroid/src/test/java/rx/android/content/ContentObservableTest.java index b20cd944..fedf76be 100644 --- a/rxandroid/src/test/java/rx/android/content/ContentObservableTest.java +++ b/rxandroid/src/test/java/rx/android/content/ContentObservableTest.java @@ -13,33 +13,16 @@ */ package rx.android.content; -import android.app.Activity; -import android.app.Fragment; import android.database.Cursor; -import android.support.v4.app.FragmentActivity; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - import rx.Observable; -import rx.Observer; import rx.Subscriber; -import rx.android.TestUtil; -import rx.observers.TestObserver; import rx.observers.TestSubscriber; import static org.mockito.Mockito.doThrow; @@ -54,118 +37,6 @@ @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE) public class ContentObservableTest { - - // support library fragments - private FragmentActivity fragmentActivity; - private android.support.v4.app.Fragment supportFragment; - - // native fragments - private Activity activity; - private Fragment fragment; - - @Mock - private Observer observer; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - supportFragment = new android.support.v4.app.Fragment(); - fragmentActivity = Robolectric.buildActivity(FragmentActivity.class).create().get(); - fragmentActivity.getSupportFragmentManager().beginTransaction().add(supportFragment, null).commit(); - - fragment = new Fragment(); - activity = Robolectric.buildActivity(Activity.class).create().get(); - activity.getFragmentManager().beginTransaction().add(fragment, null).commit(); - } - - @Test - public void itSupportsFragmentsFromTheSupportV4Library() { - ContentObservable.bindFragment(supportFragment, Observable.just("success")).subscribe(new TestObserver(observer)); - verify(observer).onNext("success"); - verify(observer).onCompleted(); - } - - @Test - public void itSupportsNativeFragments() { - ContentObservable.bindFragment(fragment, Observable.just("success")).subscribe(new TestObserver(observer)); - verify(observer).onNext("success"); - verify(observer).onCompleted(); - } - - @Test(expected = IllegalArgumentException.class) - public void itThrowsIfObjectPassedIsNotAFragment() { - ContentObservable.bindFragment("not a fragment", Observable.never()); - } - - @Test(expected = IllegalStateException.class) - public void itThrowsIfObserverCallsFromFragmentFromBackgroundThread() throws Throwable { - final Future future = Executors.newSingleThreadExecutor().submit(new Callable() { - @Override - public Object call() throws Exception { - ContentObservable.bindFragment(fragment, Observable.empty()); - return null; - } - }); - try { - future.get(1, TimeUnit.SECONDS); - } catch (ExecutionException e) { - throw e.getCause(); - } - } - - @Test - public void bindFragmentToSourceFromDifferentThread() throws InterruptedException { - CountDownLatch done = new CountDownLatch(1); - ContentObservable.bindFragment(fragment, TestUtil.atBackgroundThread(done)).subscribe(new TestObserver(observer)); - done.await(); - - Robolectric.runUiThreadTasksIncludingDelayedTasks(); - - verify(observer).onNext(TestUtil.STRING_EXPECTATION); - verify(observer).onCompleted(); - } - - @Test - public void bindSupportFragmentToSourceFromDifferentThread() throws InterruptedException { - CountDownLatch done = new CountDownLatch(1); - ContentObservable.bindFragment(supportFragment, TestUtil.atBackgroundThread(done)).subscribe(new TestObserver(observer)); - done.await(); - - Robolectric.runUiThreadTasksIncludingDelayedTasks(); - - verify(observer).onNext(TestUtil.STRING_EXPECTATION); - verify(observer).onCompleted(); - } - - @Test(expected = IllegalStateException.class) - public void itThrowsIfObserverCallsFromActivityFromBackgroundThread() throws Throwable { - final Future future = Executors.newSingleThreadExecutor().submit(new Callable() { - @Override - public Object call() throws Exception { - ContentObservable.bindActivity(activity, Observable.empty()); - return null; - } - }); - try { - future.get(1, TimeUnit.SECONDS); - } catch (ExecutionException e) { - throw e.getCause(); - } - } - - @Test - public void bindActivityToSourceFromDifferentThread() throws InterruptedException { - CountDownLatch done = new CountDownLatch(1); - ContentObservable.bindActivity(activity, TestUtil.atBackgroundThread(done)).subscribe(new TestObserver(observer)); - done.await(); - - Robolectric.runUiThreadTasksIncludingDelayedTasks(); - - verify(observer).onNext(TestUtil.STRING_EXPECTATION); - verify(observer).onCompleted(); - } - - public void givenCursorWhenFromCursorInvokedThenObservableCallsOnNextWhileHasNext() { final Subscriber subscriber = spy(new TestSubscriber()); final Cursor cursor = mock(Cursor.class); diff --git a/sample-app/src/main/java/rx/android/samples/ListFragmentActivity.java b/sample-app/src/main/java/rx/android/samples/ListFragmentActivity.java index 0f499ebf..87244989 100644 --- a/sample-app/src/main/java/rx/android/samples/ListFragmentActivity.java +++ b/sample-app/src/main/java/rx/android/samples/ListFragmentActivity.java @@ -11,7 +11,7 @@ import android.widget.ProgressBar; import rx.Observable; import rx.Subscriber; -import rx.android.content.ContentObservable; +import rx.android.app.AppObservable; import rx.android.widget.OnListViewScrollEvent; import rx.android.widget.WidgetObservable; import rx.functions.Action1; @@ -54,13 +54,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa ListView listView = (ListView) view.findViewById(android.R.id.list); listView.setAdapter(adapter); - ContentObservable.bindFragment(this, SampleObservables.numberStrings(1, 500, 100)) + AppObservable.bindFragment(this, SampleObservables.numberStrings(1, 500, 100)) .observeOn(mainThread()) .lift(new BindAdapter()) .subscribe(); final ProgressBar progressBar = (ProgressBar) view.findViewById(android.R.id.progress); - ContentObservable.bindFragment(this, WidgetObservable.listScrollEvents(listView)) + AppObservable.bindFragment(this, WidgetObservable.listScrollEvents(listView)) .subscribe(new Action1() { @Override public void call(OnListViewScrollEvent event) { diff --git a/sample-app/src/main/java/rx/android/samples/ListenInOutActivity.java b/sample-app/src/main/java/rx/android/samples/ListenInOutActivity.java index 91a1840b..94b9085b 100644 --- a/sample-app/src/main/java/rx/android/samples/ListenInOutActivity.java +++ b/sample-app/src/main/java/rx/android/samples/ListenInOutActivity.java @@ -12,7 +12,7 @@ import rx.Subscription; import rx.observables.ConnectableObservable; -import static rx.android.content.ContentObservable.bindActivity; +import static rx.android.app.AppObservable.bindActivity; /** * Activity that binds to a counting sequence and is able to listen in and out to that diff --git a/sample-app/src/main/java/rx/android/samples/ListeningFragmentActivity.java b/sample-app/src/main/java/rx/android/samples/ListeningFragmentActivity.java index 11ac1f17..2185e83a 100644 --- a/sample-app/src/main/java/rx/android/samples/ListeningFragmentActivity.java +++ b/sample-app/src/main/java/rx/android/samples/ListeningFragmentActivity.java @@ -11,7 +11,7 @@ import rx.Subscriber; import rx.Subscription; -import rx.android.content.ContentObservable; +import rx.android.app.AppObservable; import rx.observables.ConnectableObservable; import rx.subscriptions.Subscriptions; @@ -74,7 +74,7 @@ public void onViewCreated(final View view, Bundle savedInstanceState) { final TextView textView = (TextView) view.findViewById(android.R.id.text1); // re-connect to sequence - subscription = ContentObservable.bindFragment(this, strings).subscribe(new Subscriber() { + subscription = AppObservable.bindFragment(this, strings).subscribe(new Subscriber() { @Override public void onCompleted() { diff --git a/sample-app/src/main/java/rx/android/samples/RetainedFragmentActivity.java b/sample-app/src/main/java/rx/android/samples/RetainedFragmentActivity.java index 65e080dd..485fe437 100644 --- a/sample-app/src/main/java/rx/android/samples/RetainedFragmentActivity.java +++ b/sample-app/src/main/java/rx/android/samples/RetainedFragmentActivity.java @@ -18,7 +18,7 @@ import rx.functions.Func1; import rx.subscriptions.Subscriptions; -import static rx.android.content.ContentObservable.bindFragment; +import static rx.android.app.AppObservable.bindFragment; /** * Problem: