Package com.tomtom.ivi.platform.framework.api.common.util

Contains general purpose utilities to simplify common use cases, for instance: extension functions for Animation and Collection.

Types

Link copied to clipboard
class ApplicationUtil

Application class related utilities.

Link copied to clipboard
class AppOpsUtil(context: Context)

Utility class to check whether app operations (app ops) are allowed.

Link copied to clipboard
interface DefaultAnimationListener : Animation.AnimationListener

An extension of AnimationListener with default implementations, so that not every method has to be implemented.

Properties

Link copied to clipboard
val KClass<*>.enclosingClass: KClass<*>?
Link copied to clipboard
val KClass<*>.packageName: String

Functions

Link copied to clipboard
fun Collection<Boolean?>.anyFalse(): Boolean

Checks whether any element in the collection is false. Returns false if empty.

Link copied to clipboard
fun Collection<Boolean?>.anyTrue(): Boolean

Checks whether any element in the collection is true. Returns false if empty.

Link copied to clipboard
suspend fun delay(duration: Duration)

Coroutine delay convenience syntax taking a java.time.Duration instead of kotlin.time.Duration.

Link copied to clipboard
fun SharedPreferences.get(key: String, defaultValue: Any): Any

Retrieves the value of key from the preferences.

Link copied to clipboard
fun View.getBoundingRect(): Rect

Returns a Rect, bounding the view.

Link copied to clipboard
fun SharedPreferences.getDouble(key: String, defaultValue: Double): Double

Retrieves the Double value of key from the preferences.

Link copied to clipboard
fun View.getParentInputViewOrNull(): View?
Link copied to clipboard
fun <T> ArrayList<T>.indexOfFirstOrNull(predicate: (T) -> Boolean): Int?

Returns index of the first element matching the given predicate, or null if the array does not contain such element.

fun <T> Collection<T>.indexOfFirstOrNull(predicate: (T) -> Boolean): Int?

Returns index of the first element matching the given predicate, or null if the collection does not contain such element.

fun <T> Iterable<T>.indexOfFirstOrNull(predicate: (T) -> Boolean): Int?

Returns index of the first element matching the given predicate, or null if the iterable does not contain such element.

Link copied to clipboard
fun <T> ArrayList<T>.indexOfLastOrNull(predicate: (T) -> Boolean): Int?

Returns index of the last element matching the given predicate, or null if the array does not contain such element.

fun <T> Collection<T>.indexOfLastOrNull(predicate: (T) -> Boolean): Int?

Returns index of the last element matching the given predicate, or null if the collection does not contain such element.

fun <T> Iterable<T>.indexOfLastOrNull(predicate: (T) -> Boolean): Int?

Returns index of the last element matching the given predicate, or null if the iterable does not contain such element.

Link copied to clipboard
fun View.isEventWithinBounds(event: MotionEvent): Boolean

Whether the event is within the bounds of the view.

Link copied to clipboard
fun Context.isMainProcess(): Boolean

Returns true if the current process is a main one. A current process is considered the main process if its name is the same as the package name (application ID).

Link copied to clipboard
inline fun <T> isNullable(): Boolean

Checks if a type is nullable.

Link copied to clipboard
fun String.mask(): String

Applies a mask to the provided String by replacing its content by a star "*", except the last two characters that will be kept as they are.

Link copied to clipboard
fun SharedPreferences.put(key: String, newValue: Any)

Sets the key value in the preferences editor to newValue, and calls SharedPreferences.Editor.apply.

Link copied to clipboard
fun SharedPreferences.Editor.putDouble(key: String, value: Double): SharedPreferences.Editor

Sets key to the Double value value in the preferences editor, to be written back once SharedPreferences.Editor.commit or SharedPreferences.Editor.apply are called.

Link copied to clipboard
fun SharedPreferences.remove(key: String)

Removes the key value from the preferences and calls SharedPreferences.Editor.apply

Link copied to clipboard
fun Animation.setAnimationEndListener(onAnimationEnd: () -> Unit)

Sets the animation listener on the animation, dispatching only the AnimationListener.onAnimationEnd callback.

Link copied to clipboard
inline fun <T> Iterable<T>.sumByLong(selector: (T) -> Long): Long

Long version of Iterable.sumBy.

Link copied to clipboard
suspend fun <T> withTimeout(timeout: Duration, block: suspend CoroutineScope.() -> T): T

Coroutine withTimeout convenience syntax taking a java.time.Duration instead of kotlin.time.Duration.