From 2d5bfc2ae7093e6745bf3294c2a5c9d430757040 Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Wed, 30 Aug 2017 19:44:31 -0700 Subject: [PATCH] Rename to AndroidLifecycleScopeProvider --- ...=> AndroidLifecycleScopeProviderTest.java} | 18 ++++++------- ...ava => AndroidLifecycleScopeProvider.java} | 25 ++++++++++--------- ...=> TestAndroidLifecycleScopeProvider.java} | 8 +++--- 3 files changed, 26 insertions(+), 25 deletions(-) rename autodispose-android-archcomponents/src/androidTest/java/com/uber/autodispose/android/archcomponents/{ViewScopeProviderTest.java => AndroidLifecycleScopeProviderTest.java} (85%) rename autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/{LifecycleOwnerScopeProvider.java => AndroidLifecycleScopeProvider.java} (74%) rename autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/{TestLifecycleOwnerScopeProvider.java => TestAndroidLifecycleScopeProvider.java} (89%) diff --git a/autodispose-android-archcomponents/src/androidTest/java/com/uber/autodispose/android/archcomponents/ViewScopeProviderTest.java b/autodispose-android-archcomponents/src/androidTest/java/com/uber/autodispose/android/archcomponents/AndroidLifecycleScopeProviderTest.java similarity index 85% rename from autodispose-android-archcomponents/src/androidTest/java/com/uber/autodispose/android/archcomponents/ViewScopeProviderTest.java rename to autodispose-android-archcomponents/src/androidTest/java/com/uber/autodispose/android/archcomponents/AndroidLifecycleScopeProviderTest.java index af1a54b1e..c0b767cde 100644 --- a/autodispose-android-archcomponents/src/androidTest/java/com/uber/autodispose/android/archcomponents/ViewScopeProviderTest.java +++ b/autodispose-android-archcomponents/src/androidTest/java/com/uber/autodispose/android/archcomponents/AndroidLifecycleScopeProviderTest.java @@ -35,11 +35,11 @@ import static com.google.common.truth.Truth.assertThat; -@RunWith(AndroidJUnit4.class) public final class ViewScopeProviderTest { +@RunWith(AndroidJUnit4.class) public final class AndroidLifecycleScopeProviderTest { private static final RecordingObserver.Logger LOGGER = new RecordingObserver.Logger() { @Override public void log(String message) { - Log.d(ViewScopeProviderTest.class.getSimpleName(), message); + Log.d(AndroidLifecycleScopeProviderTest.class.getSimpleName(), message); } }; @@ -50,11 +50,11 @@ final PublishSubject subject = PublishSubject.create(); // Spin it up - TestLifecycleOwnerScopeProvider lifecycle = new TestLifecycleOwnerScopeProvider(); + TestAndroidLifecycleScopeProvider lifecycle = new TestAndroidLifecycleScopeProvider(); lifecycle.emit(Lifecycle.Event.ON_CREATE); lifecycle.emit(Lifecycle.Event.ON_START); lifecycle.emit(Lifecycle.Event.ON_RESUME); - subject.to(new ObservableScoper(LifecycleOwnerScopeProvider.from(lifecycle))) + subject.to(new ObservableScoper(AndroidLifecycleScopeProvider.from(lifecycle))) .subscribe(o); Disposable d = o.takeSubscribe(); @@ -81,11 +81,11 @@ PublishSubject subject = PublishSubject.create(); // Spin it up - TestLifecycleOwnerScopeProvider lifecycle = new TestLifecycleOwnerScopeProvider(); + TestAndroidLifecycleScopeProvider lifecycle = new TestAndroidLifecycleScopeProvider(); lifecycle.emit(Lifecycle.Event.ON_CREATE); lifecycle.emit(Lifecycle.Event.ON_START); lifecycle.emit(Lifecycle.Event.ON_RESUME); - subject.to(new ObservableScoper(LifecycleOwnerScopeProvider.from(lifecycle))) + subject.to(new ObservableScoper(AndroidLifecycleScopeProvider.from(lifecycle))) .subscribe(o); Disposable d = o.takeSubscribe(); @@ -101,7 +101,7 @@ final PublishSubject subject = PublishSubject.create(); UninitializedLifecycleOwner owner = new UninitializedLifecycleOwner(); - subject.to(new ObservableScoper(LifecycleOwnerScopeProvider.from(owner))) + subject.to(new ObservableScoper(AndroidLifecycleScopeProvider.from(owner))) .subscribe(o); Disposable d = o.takeSubscribe(); @@ -115,14 +115,14 @@ final RecordingObserver o = new RecordingObserver<>(LOGGER); final PublishSubject subject = PublishSubject.create(); - TestLifecycleOwnerScopeProvider lifecycle = new TestLifecycleOwnerScopeProvider(); + TestAndroidLifecycleScopeProvider lifecycle = new TestAndroidLifecycleScopeProvider(); lifecycle.emit(Lifecycle.Event.ON_CREATE); lifecycle.emit(Lifecycle.Event.ON_START); lifecycle.emit(Lifecycle.Event.ON_RESUME); lifecycle.emit(Lifecycle.Event.ON_PAUSE); lifecycle.emit(Lifecycle.Event.ON_STOP); lifecycle.emit(Lifecycle.Event.ON_DESTROY); - subject.to(new ObservableScoper(LifecycleOwnerScopeProvider.from(lifecycle))) + subject.to(new ObservableScoper(AndroidLifecycleScopeProvider.from(lifecycle))) .subscribe(o); Disposable d = o.takeSubscribe(); diff --git a/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/LifecycleOwnerScopeProvider.java b/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/AndroidLifecycleScopeProvider.java similarity index 74% rename from autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/LifecycleOwnerScopeProvider.java rename to autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/AndroidLifecycleScopeProvider.java index 38566e0a3..75c5ec738 100644 --- a/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/LifecycleOwnerScopeProvider.java +++ b/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/AndroidLifecycleScopeProvider.java @@ -24,16 +24,17 @@ import io.reactivex.functions.Function; /** - * A {@link LifecycleScopeProvider} that can provide scoping for Android {@link LifecycleOwner} - * classes. + * A {@link LifecycleScopeProvider} that can provide scoping for Android {@link Lifecycle} and + * {@link LifecycleOwner} classes. *

*


  *   myFooObservable
- *      .to(new ObservableScoper(LifecycleOwnerScopeProvider.from(lifecycleOwner)))
+ *      .to(new ObservableScoper(AndroidLifecycleScopeProvider.from(lifecycleOwner)))
  *      .subscribe();
  * 
*/ -public final class LifecycleOwnerScopeProvider implements LifecycleScopeProvider { +public final class AndroidLifecycleScopeProvider + implements LifecycleScopeProvider { private static final Function CORRESPONDING_EVENTS = new Function() { @@ -57,28 +58,28 @@ public final class LifecycleOwnerScopeProvider implements LifecycleScopeProvider }; /** - * Creates a {@link LifecycleOwnerScopeProvider} for Android LifecycleOwners. + * Creates a {@link AndroidLifecycleScopeProvider} for Android LifecycleOwners. * * @param owner the owner to scope for - * @return a {@link LifecycleOwnerScopeProvider} against this owner. + * @return a {@link AndroidLifecycleScopeProvider} against this owner. */ - public static LifecycleOwnerScopeProvider from(LifecycleOwner owner) { + public static AndroidLifecycleScopeProvider from(LifecycleOwner owner) { return from(owner.getLifecycle()); } /** - * Creates a {@link LifecycleOwnerScopeProvider} for Android Lifecycles. + * Creates a {@link AndroidLifecycleScopeProvider} for Android Lifecycles. * * @param lifecycle the lifecycle to scope for - * @return a {@link LifecycleOwnerScopeProvider} against this lifecycle. + * @return a {@link AndroidLifecycleScopeProvider} against this lifecycle. */ - public static LifecycleOwnerScopeProvider from(Lifecycle lifecycle) { - return new LifecycleOwnerScopeProvider(lifecycle); + public static AndroidLifecycleScopeProvider from(Lifecycle lifecycle) { + return new AndroidLifecycleScopeProvider(lifecycle); } private final LifecycleEventsObservable lifecycleObservable; - private LifecycleOwnerScopeProvider(Lifecycle lifecycle) { + private AndroidLifecycleScopeProvider(Lifecycle lifecycle) { this.lifecycleObservable = new LifecycleEventsObservable(lifecycle); } diff --git a/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/TestLifecycleOwnerScopeProvider.java b/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/TestAndroidLifecycleScopeProvider.java similarity index 89% rename from autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/TestLifecycleOwnerScopeProvider.java rename to autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/TestAndroidLifecycleScopeProvider.java index e111076f5..acfecb799 100644 --- a/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/TestLifecycleOwnerScopeProvider.java +++ b/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/archcomponents/TestAndroidLifecycleScopeProvider.java @@ -25,10 +25,10 @@ import static android.support.annotation.RestrictTo.Scope.TESTS; /** - * LifecycleOwnerScopeProvider implementation for testing. You can either back it with your own + * AndroidLifecycleScopeProvider implementation for testing. You can either back it with your own * instance, or just stub it in place and use its public emit() API. */ -@RestrictTo(TESTS) public final class TestLifecycleOwnerScopeProvider +@RestrictTo(TESTS) public final class TestAndroidLifecycleScopeProvider implements LifecycleRegistryOwner { private final LifecycleRegistry registry; @@ -36,7 +36,7 @@ /** * Default constructor, creates and maintains its own {@link LifecycleRegistry} under the hood. */ - public TestLifecycleOwnerScopeProvider() { + public TestAndroidLifecycleScopeProvider() { this(null); } @@ -44,7 +44,7 @@ public TestLifecycleOwnerScopeProvider() { * @param registry an optional custom {@link LifecycleRegistry} if you want to provide one. If * {@code null}, a default implementation will be created and maintained under the hood. */ - public TestLifecycleOwnerScopeProvider(@Nullable LifecycleRegistry registry) { + public TestAndroidLifecycleScopeProvider(@Nullable LifecycleRegistry registry) { this.registry = registry == null ? new LifecycleRegistry(this) : registry; }