Skip to content
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
58 changes: 23 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,46 @@ concurrency:

jobs:
build:
runs-on: macOS-latest
env:
api-level: "18"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1
uses: actions/checkout@v6

- name: Install JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v5
with:
distribution: 'zulu'
java-version: '17'
java-version: '21'

- name: Gradle cache
uses: gradle/gradle-build-action@v2
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6

# TODO split test and instrumentation into parallel builds
- name: Build and run unit tests
id: gradle
uses: gradle/gradle-build-action@v2
with:
arguments: check
run: ./gradlew check

- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.api-level }}
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.api-level }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Free up disk space for the emulator
run: |
# Remove Haskell stuff to free up space for the emulator
sudo rm -rf /usr/local/.ghcup
# Remove dotnet stuff as well
sudo rm -rf /usr/share/dotnet
df -h

- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.api-level }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
api-level: 35
arch: x86_64
disable-animations: true
disk-size: 6000M
heap-size: 600M
script: ./gradlew connectedCheck

- name: (Fail-only) Upload build reports
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Changelog
=========

Unreleased
----------

- **Fix**: Handle empty lambdas in lint checks.
- **Fix**: Use `javax.inject.Inject` for newer versions of ErrorProne.
- **Fix**: Properly propagate nullabiltiy in type params (i.e., `T extends @NonNull Object` vs `@NonNull T`).
- Raise lint target Kotlin language version to `2.0`.
- Update to RxJava `3.1.12`.
- Update minSdk to `23` to match upstream AndroidX deps.
- Update to Lint `32.2.1`.
- Update to ErrorProne `2.49.0`.

Version 2.2.1
-------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public inline fun Lifecycle.scope(
@CheckReturnValue
public inline fun <T : Any> Flowable<T>.autoDispose(
lifecycleOwner: LifecycleOwner,
untilEvent: Event? = null
untilEvent: Event? = null,
): FlowableSubscribeProxy<T> {
return if (untilEvent == null) {
this.to(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)))
Expand All @@ -114,7 +114,7 @@ public inline fun <T : Any> Flowable<T>.autoDispose(
@CheckReturnValue
public inline fun <T : Any> Observable<T>.autoDispose(
lifecycleOwner: LifecycleOwner,
untilEvent: Event? = null
untilEvent: Event? = null,
): ObservableSubscribeProxy<T> {
return if (untilEvent == null) {
this.to(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)))
Expand All @@ -135,7 +135,7 @@ public inline fun <T : Any> Observable<T>.autoDispose(
@CheckReturnValue
public inline fun <T : Any> Single<T>.autoDispose(
lifecycleOwner: LifecycleOwner,
untilEvent: Event? = null
untilEvent: Event? = null,
): SingleSubscribeProxy<T> {
return if (untilEvent == null) {
this.to(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)))
Expand All @@ -156,7 +156,7 @@ public inline fun <T : Any> Single<T>.autoDispose(
@CheckReturnValue
public inline fun <T : Any> Maybe<T>.autoDispose(
lifecycleOwner: LifecycleOwner,
untilEvent: Event? = null
untilEvent: Event? = null,
): MaybeSubscribeProxy<T> {
return if (untilEvent == null) {
this.to(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)))
Expand All @@ -177,7 +177,7 @@ public inline fun <T : Any> Maybe<T>.autoDispose(
@CheckReturnValue
public inline fun Completable.autoDispose(
lifecycleOwner: LifecycleOwner,
untilEvent: Event? = null
untilEvent: Event? = null,
): CompletableSubscribeProxy {
return if (untilEvent == null) {
this.to(AutoDispose.autoDisposable<Any>(AndroidLifecycleScopeProvider.from(lifecycleOwner)))
Expand All @@ -200,7 +200,7 @@ public inline fun Completable.autoDispose(
@CheckReturnValue
public inline fun <T : Any> ParallelFlowable<T>.autoDispose(
lifecycleOwner: LifecycleOwner,
untilEvent: Event? = null
untilEvent: Event? = null,
): ParallelFlowableSubscribeProxy<T> {
return if (untilEvent == null) {
this.to(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,13 @@ private fun CoroutineScope.asUndeferredCompletable(): Completable {
?: error(
"Scope cannot be created because it does not have a job: ${this@asUndeferredCompletable}"
)
val handle =
job.invokeOnCompletion {
when (it) {
null,
is CancellationException -> emitter.onComplete()
else -> emitter.onError(it)
}
val handle = job.invokeOnCompletion {
when (it) {
null,
is CancellationException -> emitter.onComplete()
else -> emitter.onError(it)
}
}
emitter.setCancellable(handle::dispose)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @param <E> the event type.
*/
public interface CorrespondingEventsFunction<@NonNull E> extends Function<E, E> {
public interface CorrespondingEventsFunction<E extends @NonNull Object> extends Function<E, E> {

/**
* Given an event {@code event}, returns the next corresponding event that this lifecycle should
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @see LifecycleScopes
*/
@DoNotMock(value = "Use TestLifecycleScopeProvider instead")
public interface LifecycleScopeProvider<@NonNull E> extends ScopeProvider {
public interface LifecycleScopeProvider<E extends @NonNull Object> extends ScopeProvider {

/**
* Returns a sequence of lifecycle events. Note that completion of this lifecycle will also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private LifecycleScopes() {
* @throws OutsideScopeException if the {@link LifecycleScopeProvider#correspondingEvents()}
* throws an {@link OutsideScopeException} during resolution.
*/
public static <@NonNull E> CompletableSource resolveScopeFromLifecycle(
public static <E extends @NonNull Object> CompletableSource resolveScopeFromLifecycle(
final LifecycleScopeProvider<E> provider) throws OutsideScopeException {
return resolveScopeFromLifecycle(provider, true);
}
Expand All @@ -75,7 +75,7 @@ private LifecycleScopes() {
* @throws OutsideScopeException if the {@link LifecycleScopeProvider#correspondingEvents()}
* throws an {@link OutsideScopeException} during resolution.
*/
public static <@NonNull E> CompletableSource resolveScopeFromLifecycle(
public static <E extends @NonNull Object> CompletableSource resolveScopeFromLifecycle(
final LifecycleScopeProvider<E> provider, final boolean checkEndBoundary)
throws OutsideScopeException {
E lastEvent = provider.peekLifecycle();
Expand Down Expand Up @@ -115,7 +115,7 @@ private LifecycleScopes() {
* @param endEvent the target end event
* @param <E> the lifecycle event type
*/
public static <@NonNull E> CompletableSource resolveScopeFromLifecycle(
public static <E extends @NonNull Object> CompletableSource resolveScopeFromLifecycle(
Observable<E> lifecycle, final E endEvent) {
@Nullable Comparator<E> comparator = null;
if (endEvent instanceof Comparable) {
Expand All @@ -134,7 +134,7 @@ private LifecycleScopes() {
* @param comparator an optional comparator for checking event equality.
* @param <E> the lifecycle event type
*/
public static <@NonNull E> CompletableSource resolveScopeFromLifecycle(
public static <E extends @NonNull Object> CompletableSource resolveScopeFromLifecycle(
Observable<E> lifecycle, final E endEvent, @Nullable final Comparator<E> comparator) {
Predicate<E> equalityPredicate;
if (comparator != null) {
Expand Down
18 changes: 10 additions & 8 deletions autodispose/src/main/java/autodispose2/AutoDispose.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public final class AutoDispose {
* @return an {@link AutoDisposeConverter} to transform with operators like {@link
* Observable#to(ObservableConverter)}
*/
public static <@NonNull T> AutoDisposeConverter<T> autoDisposable(final ScopeProvider provider) {
public static <T extends @NonNull Object> AutoDisposeConverter<T> autoDisposable(
final ScopeProvider provider) {
checkNotNull(provider, "provider == null");
return autoDisposable(completableOf(provider));
}
Expand All @@ -99,7 +100,8 @@ public final class AutoDispose {
* @return an {@link AutoDisposeConverter} to transform with operators like {@link
* Observable#to(ObservableConverter)}
*/
public static <@NonNull T> AutoDisposeConverter<T> autoDisposable(final CompletableSource scope) {
public static <T extends @NonNull Object> AutoDisposeConverter<T> autoDisposable(
final CompletableSource scope) {
checkNotNull(scope, "scope == null");
return new AutoDisposeConverter<T>() {
@Override
Expand Down Expand Up @@ -138,7 +140,7 @@ public void subscribe(CompletableObserver observer) {
}

@Override
public <@NonNull E extends CompletableObserver> E subscribeWith(E observer) {
public <E extends @NonNull CompletableObserver> E subscribeWith(E observer) {
return new AutoDisposeCompletable(upstream, scope).subscribeWith(observer);
}

Expand Down Expand Up @@ -196,7 +198,7 @@ public void subscribe(Subscriber<? super T> observer) {
}

@Override
public <@NonNull E extends Subscriber<? super T>> E subscribeWith(E observer) {
public <E extends @NonNull Subscriber<? super T>> E subscribeWith(E observer) {
return new AutoDisposeFlowable<>(upstream, scope).subscribeWith(observer);
}

Expand Down Expand Up @@ -263,7 +265,7 @@ public void subscribe(MaybeObserver<? super T> observer) {
}

@Override
public <@NonNull E extends MaybeObserver<? super T>> E subscribeWith(E observer) {
public <E extends @NonNull MaybeObserver<? super T>> E subscribeWith(E observer) {
return new AutoDisposeMaybe<>(upstream, scope).subscribeWith(observer);
}

Expand Down Expand Up @@ -321,7 +323,7 @@ public void subscribe(Observer<? super T> observer) {
}

@Override
public <@NonNull E extends Observer<? super T>> E subscribeWith(E observer) {
public <E extends @NonNull Observer<? super T>> E subscribeWith(E observer) {
return new AutoDisposeObservable<>(upstream, scope).subscribeWith(observer);
}

Expand Down Expand Up @@ -363,7 +365,7 @@ public Disposable subscribe(Consumer<? super T> onSuccess) {
@SuppressWarnings("NullAway") // False positive
@Override
public Disposable subscribe(
BiConsumer<@Nullable ? super T, @Nullable ? super Throwable> biConsumer) {
BiConsumer<? super @Nullable T, ? super @Nullable Throwable> biConsumer) {
return new AutoDisposeSingle<>(upstream, scope).subscribe(biConsumer);
}

Expand All @@ -379,7 +381,7 @@ public void subscribe(SingleObserver<? super T> observer) {
}

@Override
public <@NonNull E extends SingleObserver<? super T>> E subscribeWith(E observer) {
public <E extends @NonNull SingleObserver<? super T>> E subscribeWith(E observer) {
return new AutoDisposeSingle<>(upstream, scope).subscribeWith(observer);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @param <T> the type.
*/
public interface AutoDisposeConverter<@NonNull T>
public interface AutoDisposeConverter<T extends @NonNull Object>
extends FlowableConverter<T, FlowableSubscribeProxy<T>>,
ParallelFlowableConverter<T, ParallelFlowableSubscribeProxy<T>>,
ObservableConverter<T, ObservableSubscribeProxy<T>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;

final class AutoDisposeFlowable<@NonNull T> extends Flowable<T>
final class AutoDisposeFlowable<T extends @NonNull Object> extends Flowable<T>
implements FlowableSubscribeProxy<T> {
private final Publisher<T> source;
private final CompletableSource scope;
Expand Down
3 changes: 2 additions & 1 deletion autodispose/src/main/java/autodispose2/AutoDisposeMaybe.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import io.reactivex.rxjava3.core.MaybeObserver;
import io.reactivex.rxjava3.core.MaybeSource;

final class AutoDisposeMaybe<@NonNull T> extends Maybe<T> implements MaybeSubscribeProxy<T> {
final class AutoDisposeMaybe<T extends @NonNull Object> extends Maybe<T>
implements MaybeSubscribeProxy<T> {
private final MaybeSource<T> source;
private final CompletableSource scope;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import io.reactivex.rxjava3.core.ObservableSource;
import io.reactivex.rxjava3.core.Observer;

final class AutoDisposeObservable<@NonNull T> extends Observable<T>
final class AutoDisposeObservable<T extends @NonNull Object> extends Observable<T>
implements ObservableSubscribeProxy<T> {
private final ObservableSource<T> source;
private final CompletableSource scope;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.reactivex.rxjava3.parallel.ParallelFlowable;
import org.reactivestreams.Subscriber;

final class AutoDisposeParallelFlowable<@NonNull T> extends ParallelFlowable<T>
final class AutoDisposeParallelFlowable<T extends @NonNull Object> extends ParallelFlowable<T>
implements ParallelFlowableSubscribeProxy<T> {

private final ParallelFlowable<T> source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import io.reactivex.rxjava3.core.SingleObserver;
import io.reactivex.rxjava3.core.SingleSource;

final class AutoDisposeSingle<@NonNull T> extends Single<T> implements SingleSubscribeProxy<T> {
final class AutoDisposeSingle<T extends @NonNull Object> extends Single<T>
implements SingleSubscribeProxy<T> {
private final SingleSource<T> source;
private final CompletableSource scope;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import io.reactivex.rxjava3.observers.DisposableCompletableObserver;
import java.util.concurrent.atomic.AtomicReference;

final class AutoDisposingMaybeObserverImpl<@NonNull T> implements AutoDisposingMaybeObserver<T> {
final class AutoDisposingMaybeObserverImpl<T extends @NonNull Object>
implements AutoDisposingMaybeObserver<T> {

@SuppressWarnings("WeakerAccess") // Package private for synthetic accessor saving
final AtomicReference<Disposable> mainDisposable = new AtomicReference<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

final class AutoDisposingObserverImpl<@NonNull T> extends AtomicInteger
final class AutoDisposingObserverImpl<T extends @NonNull Object> extends AtomicInteger
implements AutoDisposingObserver<T> {

@SuppressWarnings("WeakerAccess") // Package private for synthetic accessor saving
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import io.reactivex.rxjava3.observers.DisposableCompletableObserver;
import java.util.concurrent.atomic.AtomicReference;

final class AutoDisposingSingleObserverImpl<@NonNull T> implements AutoDisposingSingleObserver<T> {
final class AutoDisposingSingleObserverImpl<T extends @NonNull Object>
implements AutoDisposingSingleObserver<T> {

@SuppressWarnings("WeakerAccess") // Package private for synthetic accessor saving
final AtomicReference<Disposable> mainDisposable = new AtomicReference<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;

final class AutoDisposingSubscriberImpl<@NonNull T> extends AtomicInteger
final class AutoDisposingSubscriberImpl<T extends @NonNull Object> extends AtomicInteger
implements AutoDisposingSubscriber<T> {

@SuppressWarnings("WeakerAccess") // Package private for synthetic accessor saving
Expand Down
Loading