Package-level declarations

Types

Link copied to clipboard
class Cache<K, V>

A simple in-memory cache implementation.

Link copied to clipboard
interface Mapper<in F, out T>

A generic interface for mapping an object of type F (from) to an object of type T (to).

Properties

Link copied to clipboard
Link copied to clipboard

get AccountManager

Link copied to clipboard

get ActivityManager

Link copied to clipboard

get AlarmManager

Link copied to clipboard

get AppOpsManager

Link copied to clipboard

get AppWidgetManager

Link copied to clipboard

get AudioManager

Link copied to clipboard

get BatteryManager

Link copied to clipboard

get BluetoothManager

Link copied to clipboard

get CameraManager

Link copied to clipboard

get CaptioningManager

Link copied to clipboard

get ClipboardManager

Link copied to clipboard

get ConnectivityManager

Link copied to clipboard

get ConsumerIrManager

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val CR: Int

US-ASCII CR, carriage return (13)

Link copied to clipboard
const val CRLF: String

carriage return - line feed sequence

Link copied to clipboard

get DevicePolicyManager

Link copied to clipboard

get DisplayManager

Link copied to clipboard

get downloadManager

Link copied to clipboard

get DropBoxManager

Link copied to clipboard
Link copied to clipboard
const val HT: Int

US-ASCII HT, horizontal-tab (9)

Link copied to clipboard

get InputManager

Link copied to clipboard

get InputMethodManager

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Returns true if the specified character falls into the US ASCII character set (Unicode range 0000 to 007f).

Link copied to clipboard

Returns true if the specified string consists entirely of US ASCII characters.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Checks if the string can be parsed as an integer number.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

A convenient extension property to check if a nullable object is null.

Link copied to clipboard
Link copied to clipboard

Returns true if the specified character is a whitespace character (CR, LF, SP or HT).

Returns true if the specified string consists entirely of whitespace characters.

Link copied to clipboard
Link copied to clipboard

get JobScheduler

Link copied to clipboard

get KeyguardManager

Link copied to clipboard
val <T> List<T>.lastIndex: Int
Link copied to clipboard

get LauncherApps

Link copied to clipboard

get LayoutInflater

Link copied to clipboard
const val LF: Int

US-ASCII LF, line feed (10)

Link copied to clipboard

get LocationManager

Link copied to clipboard
Link copied to clipboard

get MediaRouter

Link copied to clipboard

get MediaSessionManager

Link copied to clipboard
const val MILLISECONDS_IN_SECOND: Int = 1000
Link copied to clipboard
const val MINUTES_IN_HOUR: Int = 60
Link copied to clipboard
val YearMonth.nextMonth: YearMonth

Returns the following month.

Link copied to clipboard

get NfcManager

Link copied to clipboard

get NotificationManager

Link copied to clipboard

get NsdManager

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

A convenient inline property to retrieve the PowerManager system service.

Link copied to clipboard
val YearMonth.prevMonth: YearMonth

Returns the following month.

Link copied to clipboard

get PrintManager

Link copied to clipboard
Link copied to clipboard

get RestrictionsManager

Link copied to clipboard

get SearchManager

Link copied to clipboard
const val SECONDS_IN_HOUR: Int
Link copied to clipboard
const val SECONDS_IN_MINUTE: Int = 60
Link copied to clipboard

get SensorManager

Link copied to clipboard
const val SP: Int

US-ASCII SP, space (32)

Link copied to clipboard

get StorageManager

Link copied to clipboard

get StorageStatsManager

Link copied to clipboard

An extension property to simplify getting the class name for logging purposes. It returns the string representation of the class, which is suitable for use as a Logcat tag.

Link copied to clipboard

get TelecomManager

Link copied to clipboard

get TelephonyManager

Link copied to clipboard

get TextServicesManager

Link copied to clipboard

Checks if the string can be parsed as a decimal number (Double).

Link copied to clipboard
Link copied to clipboard

get TvInputManager

Link copied to clipboard

get UiModeManager

Link copied to clipboard

get UsbManager

Link copied to clipboard

get UserManager

Link copied to clipboard

get WallpaperManager

Link copied to clipboard

get WifiManager

Link copied to clipboard

get WifiP2pManager

Link copied to clipboard

get WindowManager

Link copied to clipboard

Functions

Link copied to clipboard
fun Int.asPercentage(ofValue: Int): Int
fun Long.asPercentage(ofValue: Long): Long

Calculates what fraction this number is of a given value.

Link copied to clipboard
fun YearMonth.atDay(day: Int): LocalDate

Combines this year-month with a day-of-month to create a LocalDate. This returns a LocalDate with the year and month from this object, and the provided day-of-month.

Link copied to clipboard

Converts this Float value from Celsius to Fahrenheit.

Link copied to clipboard

Converts this Float value from centimetres to inches.

Link copied to clipboard
fun <T> List<T>.chunkedBy(predicate: (T) -> Boolean): List<List<T>>

Splits this collection into a list of lists, where each inner list is a chunk of elements separated by an element that matches the given predicate. The separator element itself is not included in the resulting chunks.

Link copied to clipboard
fun Float.clamp(min: Float, max: Float): Float

Clamps this value to be within the specified range.

fun Int.clamp(min: Int, max: Int): Int

Constrains this value to be within a specified range.

Link copied to clipboard
operator fun <T : Comparable<T>> ClosedRange<T>.contains(other: ClosedRange<T>): Boolean

Returns true if the given range contains the other range

Link copied to clipboard

Checks if the string contains any of the specified symbols.

Link copied to clipboard
fun createTimestamp(hours: Int, minutes: Int, seconds: Int): Timestamp

Creates a Timestamp from the given hours, minutes, and seconds.

Link copied to clipboard

Delete all files in a directory using recurssion

Link copied to clipboard
@ChecksSdkIntAtLeast(parameter = 0, lambda = 1)
inline fun doWithApi(sdkCode: Int, block: () -> Unit)
Link copied to clipboard
@ChecksSdkIntAtLeast(parameter = 0, lambda = 1)
inline fun doWithAtLeastApi(sdkCode: Int, block: () -> Unit)
Link copied to clipboard
@ChecksSdkIntAtLeast(parameter = 0, lambda = 1)
inline fun doWithAtMostApi(sdkCode: Int, block: () -> Unit)
Link copied to clipboard
@ChecksSdkIntAtLeast(parameter = 0, lambda = 1)
inline fun doWithHigherApi(sdkCode: Int, block: () -> Unit)
Link copied to clipboard
@ChecksSdkIntAtLeast(parameter = 0, lambda = 1)
inline fun doWithLowerApi(sdkCode: Int, block: () -> Unit)
Link copied to clipboard
fun <T> List<T>.duplicates(): List<T>

Returns a set containing all elements that are contained more than once in this collection.

Link copied to clipboard

Converts a temperature value from Fahrenheit to Celsius.

Link copied to clipboard
fun Double.formatAsPrice(currencySymbol: String = "$"): String
fun Float.formatAsPrice(currencySymbol: String = "$"): String
Link copied to clipboard
fun Number.formatDecimal(digits: Int = 2): String
Link copied to clipboard
Link copied to clipboard
operator fun Int.get(digit: Int): Int

Retrieves the digit at a specific position (from right to left, 0-indexed) in an integer.

operator fun String.get(range: IntRange): String

Allows slicing a string using an IntRange with an inclusive end.

Link copied to clipboard
fun <T : Any> T.getClass(): KClass<T>

Extension function to get the KClass of any non-null object. This is a convenient alternative to T::class when dealing with generic types, or simply as a replacement for this.javaClass.kotlin.

Link copied to clipboard
Link copied to clipboard

get human-readable size string from given file

Link copied to clipboard

Return date in yyyy-MM-dd format.

Link copied to clipboard
Link copied to clipboard
inline fun <T1, T2, R> ifLet(p1: T1?, p2: T2?, block: (T1, T2) -> R?): R?

Takes two nullable values along with a lambda function that operates on them and returns a nullable result.

Link copied to clipboard
fun <T> T?.ifNotNull(action: (T) -> Unit): T?

Executes a given block of code if the value of this nullable type is not null. This function allows for safe, chained operations on a nullable object, similar to let, but it returns the original receiver (this) instead of the result of the lambda. This is useful for performing side effects on a non-null value without altering the flow.

Link copied to clipboard
fun <T> T?.ifNull(action: () -> Unit): T?

Executes a given action if this nullable type is null. This function allows for chaining operations and executing side effects when a value is null.

Link copied to clipboard

Converts this Float value from inches to centimetres.

Link copied to clipboard

Checks if this integer is within the specified range.

Link copied to clipboard
fun Number.InRangeOr(min: Number, max: Number, default: Number): Number
Link copied to clipboard
fun Int.inRangeOr(min: Int, max: Int, default: Int): Int

Returns this number if it's within the specified range (inclusive), or the default value otherwise.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun YearMonth.isLeapYear(): Boolean

Determines if a given year is a leap year. A year is a leap year if it is divisible by 4, unless it is a century year not divisible by 400.

Link copied to clipboard
Link copied to clipboard

Checks if a list is not null and not empty.

Link copied to clipboard

Checks if a list is null or empty.

Link copied to clipboard

Checks if the nullable Boolean is true.

Link copied to clipboard
inline fun <T> Any?.isTypeOfOrNull(): Boolean

Checks if the object is of the specified generic type T or is null. This is a convenient shorthand for this is T?.

Link copied to clipboard
Link copied to clipboard

Converts this Float value from kilograms to pounds.

Link copied to clipboard

Converts this Float value from kilometres to miles.

Link copied to clipboard
Link copied to clipboard
inline fun <T, R> List<T>?.mapIfNotEmpty(transform: (T) -> R): List<R>

Returns a list containing the results of applying the given transform function to each element in the original list if the list is not null or empty. If the list is null or empty, it returns an empty list.

Link copied to clipboard
inline fun <T, R> T?.mapOr(default: R, transform: (T) -> R?): R

Maps this nullable value to a new value using the given transformation function, or returns the default value if this is null or the transformation returns null.

Link copied to clipboard
fun <K, V> Collection<Map<K, V>>.merge(valueMergeFunction: (List<V>) -> V): Map<K, V>

Merges the given Collection of type-equivalent Maps together, while grouping the values of each key together and finally applying the given lambds to each value to merge the list of values of each key into a single value such that the returned map has the same type-signature again.

Link copied to clipboard

Converts this Float value from miles to kilometers.

Link copied to clipboard
fun YearMonth.Companion.now(zone: TimeZone = TimeZone.currentSystemDefault()): YearMonth

Obtains the current year-month from the system clock in the specified time-zone.

Link copied to clipboard
inline fun Any?.onIsNull(block: () -> Unit)

Executes the given block only if this object is null.

Link copied to clipboard
inline fun Any?.onNotNull(block: () -> Unit)

Executes the given block only if the receiver object is not null.

Link copied to clipboard
fun <T> T?.or(default: T): T

Returns this value if it's not null, or the default value otherwise.

fun <T> List<T>?.or(index: Int, default: T): T

Returns the element at the specified index in the list, or the default value if the list is null or the index is out of bounds.

Link copied to clipboard
fun <T> T?.orDefault(defaultValue: T): T

Returns the value of this nullable type if it's not null, or a provided default value if it is. This is a concise alternative to the elvis operator (?:) for cases where the default value is computed or retrieved from a function.

Link copied to clipboard
fun <T> List<T>?.orEmpty(): List<T>
fun <K, V> Map<K, V>?.orEmpty(): Map<K, V>
fun <T> Set<T>?.orEmpty(): Set<T>
Link copied to clipboard
Link copied to clipboard
fun <T> T?.orThrow(exception: () -> Exception): T

Returns the encapsulated value if it's not null, otherwise throws the specified exception. This is an alternative to the !! operator, allowing for a more descriptive exception to be thrown when a value is unexpectedly null.

Link copied to clipboard
Link copied to clipboard

Returns true if the given range overlaps with the other range

Link copied to clipboard
fun <T> Collection<T>.percentage(predicate: (T) -> Boolean): Float

Returns how many percent of the items of the given Collection satisfy the predicate.

Link copied to clipboard
fun Int.percentageOf(total: Int): Float
Link copied to clipboard

Converts this Float value from pounds to kilograms.

Link copied to clipboard
fun Any?.printToLog(tag: String = "DEBUG_LOG")
Link copied to clipboard

read file to string

Link copied to clipboard
fun <T> List<T>.replaceAll(oldValue: T, newValue: T): List<T>

Returns a new list with all occurrences of the specified oldValue replaced by the newValue.

Link copied to clipboard
fun Float.roundTo(decimals: Int): Float
Link copied to clipboard
fun <T> List<T>.second(): T

Returns the second element.

Link copied to clipboard
fun <T> List<T>.secondOrNull(): T?
Link copied to clipboard
fun secondsToPrettyTime(milliseconds: Long): String
Link copied to clipboard
fun <T> List<T>.split(predicate: (T) -> Boolean): Pair<List<T>, List<T>>
Link copied to clipboard
fun <T> Iterable<T>.sumByLong(selector: (T) -> Long): Long
Link copied to clipboard
fun <A, B> Pair<A, B>.swap(): Pair<B, A>

Swaps the order of the elements of the given Pair in a type-safe manner. Example: Pair("David", 32).swap() -> Pair(32, "David")

fun Number.swap(newNumber: Number): Pair<Number, Number>
fun <T> MutableList<T>.swap(index1: Int, index2: Int)
Link copied to clipboard
fun <T> List<T>.takeIfNotEmpty(): List<T>?

Returns this list if it's not empty, or null if it is empty. This is a shorthand for ifEmpty { null }.

Link copied to clipboard
fun <T> Collection<T>.takePercentage(percentage: Double): List<T>

Returns the first n percent of items out of the given Collection. The precentage gets rounded to the next integer regardless of the size of the returned List

Link copied to clipboard
operator fun String.times(n: Int): String

Repeats the string n times.

Link copied to clipboard

Converts the string to title case.

Link copied to clipboard
infix fun <A, B, C> Pair<A, B>.to(third: C): Triple<A, B, C>

Creates a Triple from a Pair and a third value. This allows for a chained call like "A" to "B" to "C".

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Calculate size into human-readable size

Link copied to clipboard
fun Int.toPercentage(total: Int): Float

Calculates the percentage that this number represents out of a given total.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <T> T.toResult(): Result<T>
Link copied to clipboard
inline fun Any?.toString(): String

A null-safe version of the standard toString() function.

Link copied to clipboard
fun Int.toWords(language: String = "en", country: String = "US"): String
Link copied to clipboard
inline fun Boolean.whenFalse(block: (Boolean) -> Unit): Boolean

Executes the given block if the Boolean value is false.

Link copied to clipboard
inline fun <T> List<T>?.whenNotEmpty(block: (List<T>) -> Unit)

Executes the given block if this nullable list is not null and not empty.

Link copied to clipboard
inline fun Boolean.whenTrue(block: (Boolean) -> Unit): Boolean

Executes the given block if the Boolean is true.