Add universal disappearing messages.

This commit is contained in:
Cody Henthorne
2021-05-18 15:19:33 -04:00
committed by Greyson Parrelli
parent 8c6a88374b
commit defd5e8047
70 changed files with 1513 additions and 251 deletions

View File

@@ -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];

View File

@@ -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)
}

View File

@@ -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())
}
}
}
}