mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 16:49:40 +01:00
Add universal disappearing messages.
This commit is contained in:
committed by
Greyson Parrelli
parent
8c6a88374b
commit
defd5e8047
@@ -151,6 +151,10 @@ public final class SqlUtil {
|
||||
return new Query(column + " IN (" + query.toString() + ")", buildArgs(args));
|
||||
}
|
||||
|
||||
public static @NonNull Query buildQuery(@NonNull String where, @NonNull Object... args) {
|
||||
return new SqlUtil.Query(where, SqlUtil.buildArgs(args));
|
||||
}
|
||||
|
||||
public static String[] appendArg(@NonNull String[] args, String addition) {
|
||||
String[] output = new String[args.length + 1];
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.thoughtcrime.securesms.util.livedata
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
|
||||
fun <T, R> LiveData<T>.distinctUntilChanged(selector: (T) -> R): LiveData<T> {
|
||||
return LiveDataUtil.distinctUntilChanged(this, selector)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.thoughtcrime.securesms.util.livedata
|
||||
|
||||
/**
|
||||
* Provide a general representation of a discrete process. States are idle,
|
||||
* working, success, and failure.
|
||||
*/
|
||||
sealed class ProcessState<T> {
|
||||
class Idle<T> : ProcessState<T>()
|
||||
class Working<T> : ProcessState<T>()
|
||||
data class Success<T>(val result: T) : ProcessState<T>()
|
||||
data class Failure<T>(val throwable: Throwable?) : ProcessState<T>()
|
||||
|
||||
companion object {
|
||||
fun <T> fromResult(result: Result<T>): ProcessState<T> {
|
||||
return if (result.isSuccess) {
|
||||
Success(result.getOrThrow())
|
||||
} else {
|
||||
Failure(result.exceptionOrNull())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user