Package-level declarations

Types

Link copied to clipboard
object JSONParceler : Parceler<Map<String, Any>>

Implementation of a Parceler to be used with @Parcelize to serialize JSON objects.

Properties

Link copied to clipboard

Returns the file extension of the URL.

Functions

Link copied to clipboard

If this string starts with the given prefix, returns this string. Otherwise, returns a copy of this string after adding the prefix.

Link copied to clipboard

If this string ends with the given suffix, returns this string. Otherwise, returns a copy of this string after adding the suffix.

Link copied to clipboard
Link copied to clipboard
fun <T1, T2, R> StateFlow<T1>.combineStateIn(coroutineScope: CoroutineScope, flow: StateFlow<T2>, transform: (a: T1, b: T2) -> R): StateFlow<R>

Transforms the values of two StateFlows and stores the result in a new StateFlow using the given coroutineScope.

Link copied to clipboard
fun Double.equalsDelta(other: Double, delta: Double = 0.001): Boolean
fun Float.equalsDelta(other: Float, delta: Float = 0.001f): Boolean
Link copied to clipboard
inline fun <T : Throwable> Throwable.findInstance(): T?

Finds the first cause instance of the given type.

Link copied to clipboard
fun ByteArray.inflate(nowrap: Boolean = false, bufferSize: Int = 32 * 1024): Try<ByteArray, DataFormatException>

Inflates a ZIP-compressed ByteArray.

Link copied to clipboard

Returns whether the other is a descendant of this file.

Link copied to clipboard
inline fun <T> JSONArray.mapNotNull(transform: (Any) -> T?): List<T>

Returns a list containing the results of applying the given transform function to each element in the original JSONArray. If the tranform returns null, it is not included in the output list.

fun <T> JSONObject.mapNotNull(transform: (Pair<String, Any>) -> T?): List<T>

Returns a list containing the results of applying the given transform function to each element in the original JSONObject. If the tranform returns null, it is not included in the output list.

Link copied to clipboard
fun <T, M> StateFlow<T>.mapStateIn(coroutineScope: CoroutineScope, transform: (value: T) -> M): StateFlow<M>

Transforms the value of a StateFlow and stores it in a new StateFlow using the given coroutineScope.

Link copied to clipboard
fun File.md5(): String?

Computes the MD5 hash of the file.

Computes the MD5 hash of the byte array.

Link copied to clipboard
fun JSONObject.optNullableBoolean(name: String, remove: Boolean = false): Boolean?

Returns the value mapped by name if it exists, coercing it if necessary, or null if no such mapping exists. If remove is true, then the mapping will be removed from the JSONObject.

Link copied to clipboard
fun JSONObject.optNullableDouble(name: String, remove: Boolean = false): Double?

Returns the value mapped by name if it exists, coercing it if necessary, or null if no such mapping exists. If remove is true, then the mapping will be removed from the JSONObject.

Link copied to clipboard
fun JSONObject.optNullableInt(name: String, remove: Boolean = false): Int?

Returns the value mapped by name if it exists, coercing it if necessary, or null if no such mapping exists. If remove is true, then the mapping will be removed from the JSONObject.

Link copied to clipboard
fun JSONObject.optNullableLong(name: String, remove: Boolean = false): Long?

Returns the value mapped by name if it exists, coercing it if necessary, or null if no such mapping exists. If remove is true, then the mapping will be removed from the JSONObject.

Link copied to clipboard
fun JSONObject.optNullableString(name: String, remove: Boolean = false): String?

Returns the value mapped by name if it exists, or null if no such mapping exists, it is not a string or it is empty. If remove is true, then the mapping will be removed from the JSONObject.

Link copied to clipboard
fun JSONObject.optPositiveDouble(name: String, fallback: Double = -1.0, remove: Boolean = false): Double?

Returns the value mapped by name if it exists and is a positive double or can be coerced to a positive double, or fallback otherwise. If remove is true, then the mapping will be removed from the JSONObject.

Link copied to clipboard
fun JSONObject.optPositiveInt(name: String, fallback: Int = -1, remove: Boolean = false): Int?

Returns the value mapped by name if it exists and is a positive integer or can be coerced to a positive integer, or fallback otherwise. If remove is true, then the mapping will be removed from the JSONObject.

Link copied to clipboard

Returns the value mapped by name if it exists and is either a JSONArray of String or a single String value, or an empty list otherwise. If remove is true, then the mapping will be removed from the JSONObject.

Link copied to clipboard
fun JSONObject.putIfNotEmpty(name: String, jsonArray: JSONArray?)

Maps name to jsonArray, clobbering any existing name/value mapping with the same name. If the JSONArray is empty, any existing mapping for name is removed.

fun JSONObject.putIfNotEmpty(name: String, jsonObject: JSONObject?)

Maps name to jsonObject, clobbering any existing name/value mapping with the same name. If the JSONObject is empty, any existing mapping for name is removed.

fun JSONObject.putIfNotEmpty(name: String, jsonable: JSONable?)

Maps name to jsonable after converting it to a JSONObject, clobbering any existing name/value mapping with the same name. If the JSONObject argument is empty, any existing mapping for name is removed.

Link copied to clipboard
Link copied to clipboard

Unwraps recursively the JSONArray to a List.

Link copied to clipboard

Unwraps recursively the JSONObject to a Map.

Link copied to clipboard
suspend fun Bitmap.toPng(quality: Int = 100): ByteArray?
Link copied to clipboard
inline fun <T> tryOr(default: T, closure: () -> T): T

Returns the result of the given closure, or default if an Exception was raised.

Link copied to clipboard
inline fun <T> tryOrLog(closure: () -> T): T?

Returns the result of the given closure, or null if an Exception was raised. The Exception will be logged.

Link copied to clipboard
inline fun <T> tryOrNull(closure: () -> T): T?

Returns the result of the given closure, or null if an Exception was raised.