Update AGP to 8.0

Co-authored-by: Greyson Parrelli <greyson@signal.org>
This commit is contained in:
Cody Henthorne
2023-06-20 14:49:00 -04:00
committed by Nicholas Tinsley
parent ed4a1d6ddd
commit 53673be5cb
29 changed files with 643 additions and 1768 deletions

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2023 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.signal.core.util.concurrent
import io.reactivex.rxjava3.core.Maybe
import io.reactivex.rxjava3.exceptions.Exceptions
import io.reactivex.rxjava3.plugins.RxJavaPlugins
/**
* Kotlin 1.8 started respecting RxJava nullability annotations but RxJava has some oddities where it breaks those rules.
* This essentially re-implements [Maybe.fromCallable] with an emitter so we don't have to do it everywhere ourselves.
*/
object MaybeCompat {
fun <T : Any> fromCallable(callable: () -> T?): Maybe<T> {
return Maybe.create { emitter ->
val result = try {
callable()
} catch (e: Throwable) {
Exceptions.throwIfFatal(e)
if (!emitter.isDisposed) {
emitter.onError(e)
} else {
RxJavaPlugins.onError(e)
}
return@create
}
if (!emitter.isDisposed) {
if (result == null) {
emitter.onComplete()
} else {
emitter.onSuccess(result)
}
}
}
}
}