From 285cab5c4e78a58bb68dc129c04e3cc4cd863c06 Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Fri, 20 Oct 2017 21:33:55 -0700 Subject: [PATCH 1/3] Update to kotlin 1.1.51 --- gradle/dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 297904b20..7f013ae71 100755 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -18,7 +18,7 @@ def versions = [ androidTest: '0.5', archComponents: '1.0.0-rc1', errorProne: '2.1.1', - kotlin: '1.1.50', + kotlin: '1.1.51', support: '26.1.0' ] From caaf21d38003bb03c2d281909f19a649106f88fc Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Fri, 20 Oct 2017 21:35:49 -0700 Subject: [PATCH 2/3] Add missing from(owner, boundaryResolver) for Owners --- .../lifecycle/AndroidLifecycleScopeProvider.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/android/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProvider.java b/android/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProvider.java index 6091cc922..5589ca13e 100644 --- a/android/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProvider.java +++ b/android/autodispose-android-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/AndroidLifecycleScopeProvider.java @@ -102,6 +102,19 @@ public static AndroidLifecycleScopeProvider from( return from(lifecycle, new UntilEventFunction(untilEvent)); } + /** + * Creates a {@link AndroidLifecycleScopeProvider} for Android Lifecycles. + * + * @param owner the owner to scope for. + * @param boundaryResolver function that resolves the event boundary. + * @return a {@link AndroidLifecycleScopeProvider} against this owner. + */ + public static AndroidLifecycleScopeProvider from( + LifecycleOwner owner, + Function boundaryResolver) { + return from(owner.getLifecycle(), boundaryResolver); + } + /** * Creates a {@link AndroidLifecycleScopeProvider} for Android Lifecycles. * From 32e5c564a2da708566d7ba876eb86d84247789a5 Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Fri, 20 Oct 2017 21:36:01 -0700 Subject: [PATCH 3/3] Add kotlin extensions for boundaryResolver overloads --- .../lifecycle/autodisposeAndroidLifecycle.kt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/android/autodispose-android-archcomponents-kotlin/src/main/kotlin/com/uber/autodispose/android/lifecycle/autodisposeAndroidLifecycle.kt b/android/autodispose-android-archcomponents-kotlin/src/main/kotlin/com/uber/autodispose/android/lifecycle/autodisposeAndroidLifecycle.kt index d9e5f7bcc..d61f468ef 100644 --- a/android/autodispose-android-archcomponents-kotlin/src/main/kotlin/com/uber/autodispose/android/lifecycle/autodisposeAndroidLifecycle.kt +++ b/android/autodispose-android-archcomponents-kotlin/src/main/kotlin/com/uber/autodispose/android/lifecycle/autodisposeAndroidLifecycle.kt @@ -19,9 +19,11 @@ package com.uber.autodispose.android.lifecycle import android.arch.lifecycle.Lifecycle +import android.arch.lifecycle.Lifecycle.Event import android.arch.lifecycle.LifecycleOwner import com.uber.autodispose.LifecycleScopeProvider import io.reactivex.annotations.CheckReturnValue +import io.reactivex.functions.Function /** * Extension that returns a [LifecycleScopeProvider] for this [LifecycleOwner]. @@ -38,6 +40,15 @@ inline fun LifecycleOwner.scope(): LifecycleScopeProvider<*> = AndroidLifecycleS inline fun LifecycleOwner.scope(untilEvent: Lifecycle.Event): LifecycleScopeProvider<*> = AndroidLifecycleScopeProvider.from(this, untilEvent) +/** + * Extension that returns a [LifecycleScopeProvider] for this [LifecycleOwner]. + * + * @param boundaryResolver function that resolves the event boundary. + */ +@CheckReturnValue +inline fun LifecycleOwner.scope(boundaryResolver: Function): LifecycleScopeProvider<*> + = AndroidLifecycleScopeProvider.from(this, boundaryResolver) + /** * Extension that returns a [LifecycleScopeProvider] for this [Lifecycle]. */ @@ -52,3 +63,12 @@ inline fun Lifecycle.scope(): LifecycleScopeProvider<*> = AndroidLifecycleScopeP @CheckReturnValue inline fun Lifecycle.scope(untilEvent: Lifecycle.Event): LifecycleScopeProvider<*> = AndroidLifecycleScopeProvider.from(this, untilEvent) + +/** + * Extension that returns a [LifecycleScopeProvider] for this [Lifecycle]. + * + * @param boundaryResolver function that resolves the event boundary. + */ +@CheckReturnValue +inline fun Lifecycle.scope(boundaryResolver: Function): LifecycleScopeProvider<*> + = AndroidLifecycleScopeProvider.from(this, boundaryResolver)