Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Default/Kotlin LifecycleScopeProvider interfaces #275

Merged
merged 7 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,14 @@
package com.uber.autodispose.lifecycle.jdk8;

import com.uber.autodispose.lifecycle.LifecycleScopeProvider;
import com.uber.autodispose.lifecycle.LifecycleScopes;
import io.reactivex.CompletableSource;

/**
* A convenience {@link LifecycleScopeProvider} that has a default implementation for
* {@link #requestScope()}.
*
* @param <E> the lifecycle event type.
* @deprecated this functionality is lifted directly into {@link LifecycleScopeProvider} now.
*/
@Deprecated
public interface DefaultLifecycleScopeProvider<E> extends LifecycleScopeProvider<E> {

@Override default CompletableSource requestScope() {
return LifecycleScopes.resolveScopeFromLifecycle(this);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@

package com.uber.autodispose.lifecycle

import com.uber.autodispose.lifecycle.LifecycleScopes.resolveScopeFromLifecycle
import io.reactivex.CompletableSource
import kotlin.DeprecationLevel.HIDDEN

/**
* A convenience [LifecycleScopeProvider] that has a default implementation for
* [requestScope].
*
* @param <E> the lifecycle event type.
*/
interface KotlinLifecycleScopeProvider<E> : LifecycleScopeProvider<E> {
override fun requestScope(): CompletableSource = resolveScopeFromLifecycle(this)
}
@Deprecated(
message = "This functionality is now pushed up into LifecycleScopeProvider directly.",
replaceWith = ReplaceWith(
expression = "LifecycleScopeProvider<FIXME>", // Unfortunately we can't make this better yet https://youtrack.jetbrains.com/issue/KT-21195
imports = ["com.uber.autodispose.lifecycle.LifecycleScopeProvider"]
),
level = HIDDEN
)
interface KotlinLifecycleScopeProvider<E> : LifecycleScopeProvider<E>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.uber.autodispose.ScopeProvider;
import com.uber.autodispose.internal.DoNotMock;
import io.reactivex.Completable;
import io.reactivex.CompletableSource;
import io.reactivex.Observable;
import io.reactivex.annotations.CheckReturnValue;
import io.reactivex.annotations.Nullable;
Expand Down Expand Up @@ -54,4 +55,8 @@ public interface LifecycleScopeProvider<E> extends ScopeProvider {
* LifecycleNotStartedException}.
*/
@Nullable E peekLifecycle();

@Override default CompletableSource requestScope() {
return LifecycleScopes.resolveScopeFromLifecycle(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import com.uber.autodispose.lifecycle.CorrespondingEventsFunction;
import com.uber.autodispose.lifecycle.LifecycleEndedException;
import com.uber.autodispose.lifecycle.LifecycleScopeProvider;
import com.uber.autodispose.lifecycle.LifecycleScopes;
import io.reactivex.CompletableSource;
import io.reactivex.Observable;
import io.reactivex.subjects.BehaviorSubject;

Expand Down Expand Up @@ -76,10 +74,6 @@ public enum ActivityEvent {
return lifecycleEvents.getValue();
}

@Override public CompletableSource requestScope() {
return LifecycleScopes.resolveScopeFromLifecycle(this);
}

@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
lifecycleEvents.onNext(ActivityEvent.CREATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.Nullable;
import android.view.View;
import androidx.annotation.Nullable;
import com.uber.autodispose.lifecycle.CorrespondingEventsFunction;
import com.uber.autodispose.lifecycle.LifecycleEndedException;
import com.uber.autodispose.lifecycle.LifecycleScopeProvider;
import com.uber.autodispose.lifecycle.LifecycleScopes;
import io.reactivex.CompletableSource;
import io.reactivex.Observable;
import io.reactivex.subjects.BehaviorSubject;

Expand Down Expand Up @@ -86,10 +84,6 @@ public enum FragmentEvent {
return lifecycleEvents.getValue();
}

@Override public CompletableSource requestScope() {
return LifecycleScopes.resolveScopeFromLifecycle(this);
}

@Override public void onAttach(Context context) {
super.onAttach(context);
lifecycleEvents.onNext(FragmentEvent.ATTACH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@

import android.content.Context;
import android.os.Build;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.uber.autodispose.android.ViewScopeProvider;
import com.uber.autodispose.lifecycle.CorrespondingEventsFunction;
import com.uber.autodispose.lifecycle.LifecycleEndedException;
import com.uber.autodispose.lifecycle.LifecycleScopeProvider;
import com.uber.autodispose.lifecycle.LifecycleScopes;
import io.reactivex.CompletableSource;
import io.reactivex.Observable;
import io.reactivex.subjects.BehaviorSubject;

Expand Down Expand Up @@ -116,8 +114,4 @@ public ViewEvent peekLifecycle() {
//noinspection ConstantConditions only in layoutlib
return lifecycleEvents.getValue();
}

@Override public CompletableSource requestScope() {
return LifecycleScopes.resolveScopeFromLifecycle(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import com.uber.autodispose.lifecycle.CorrespondingEventsFunction;
import com.uber.autodispose.lifecycle.LifecycleEndedException;
import com.uber.autodispose.lifecycle.LifecycleScopeProvider;
import com.uber.autodispose.lifecycle.LifecycleScopes;
import io.reactivex.CompletableSource;
import io.reactivex.Observable;
import io.reactivex.annotations.Nullable;
import io.reactivex.subjects.BehaviorSubject;
Expand Down Expand Up @@ -67,10 +65,6 @@ public AutoDisposeViewHolder(View itemView) {
return lifecycleEvents.getValue();
}

@Override public CompletableSource requestScope() {
return LifecycleScopes.resolveScopeFromLifecycle(this);
}

@Override protected void onBind() {
lifecycleEvents.onNext(ViewHolderEvent.BIND);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ import android.os.Bundle
import com.uber.autodispose.lifecycle.CorrespondingEventsFunction
import com.uber.autodispose.lifecycle.LifecycleEndedException
import com.uber.autodispose.lifecycle.LifecycleScopeProvider
import com.uber.autodispose.lifecycle.LifecycleScopes
import com.uber.autodispose.recipes.AutoDisposeActivityKotlin.ActivityEvent
import com.uber.autodispose.recipes.AutoDisposeActivityKotlin.ActivityEvent.CREATE
import com.uber.autodispose.recipes.AutoDisposeActivityKotlin.ActivityEvent.DESTROY
import com.uber.autodispose.recipes.AutoDisposeActivityKotlin.ActivityEvent.PAUSE
import com.uber.autodispose.recipes.AutoDisposeActivityKotlin.ActivityEvent.RESUME
import com.uber.autodispose.recipes.AutoDisposeActivityKotlin.ActivityEvent.START
import com.uber.autodispose.recipes.AutoDisposeActivityKotlin.ActivityEvent.STOP
import io.reactivex.CompletableSource
import io.reactivex.Observable
import io.reactivex.subjects.BehaviorSubject

Expand Down Expand Up @@ -82,10 +80,6 @@ abstract class AutoDisposeActivityKotlin : Activity(), LifecycleScopeProvider<Ac
super.onStop()
}

override fun requestScope(): CompletableSource {
return LifecycleScopes.resolveScopeFromLifecycle(this)
}

override fun onDestroy() {
lifecycleEvents.onNext(ActivityEvent.DESTROY)
super.onDestroy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import androidx.fragment.app.Fragment
import com.uber.autodispose.lifecycle.CorrespondingEventsFunction
import com.uber.autodispose.lifecycle.LifecycleEndedException
import com.uber.autodispose.lifecycle.LifecycleScopeProvider
import com.uber.autodispose.lifecycle.LifecycleScopes
import com.uber.autodispose.recipes.AutoDisposeFragmentKotlin.FragmentEvent
import com.uber.autodispose.recipes.AutoDisposeFragmentKotlin.FragmentEvent.ATTACH
import com.uber.autodispose.recipes.AutoDisposeFragmentKotlin.FragmentEvent.CREATE
Expand All @@ -35,7 +34,6 @@ import com.uber.autodispose.recipes.AutoDisposeFragmentKotlin.FragmentEvent.PAUS
import com.uber.autodispose.recipes.AutoDisposeFragmentKotlin.FragmentEvent.RESUME
import com.uber.autodispose.recipes.AutoDisposeFragmentKotlin.FragmentEvent.START
import com.uber.autodispose.recipes.AutoDisposeFragmentKotlin.FragmentEvent.STOP
import io.reactivex.CompletableSource
import io.reactivex.Observable
import io.reactivex.subjects.BehaviorSubject

Expand Down Expand Up @@ -63,10 +61,6 @@ abstract class AutoDisposeFragmentKotlin : Fragment(), LifecycleScopeProvider<Fr
return lifecycleEvents.value
}

override fun requestScope(): CompletableSource {
return LifecycleScopes.resolveScopeFromLifecycle(this)
}

override fun onAttach(context: Context) {
super.onAttach(context)
lifecycleEvents.onNext(FragmentEvent.ATTACH)
Expand Down
Loading