Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
class DataExtra<T>(val key: String)
Link copied to clipboard
class InputStreamVolleyRequest(post: Int, url: String, listener: Response.Listener<ByteArray>, errorListener: Response.ErrorListener, params: Map<String, String>, requestHeaders: Map<String, String>) : Request<ByteArray>
Link copied to clipboard
data class ValueMax<T : Number> constructor(val value: T, val max: T)

Initializes the ValueMax class

Functions

Link copied to clipboard
Link copied to clipboard
fun <A> MutableList<A>.append(value: A?): MutableList<A>

Adds value to the end of the list if not null, and returns this.

fun <A, B> MutableMap<A, B>.append(key: A, value: B): MutableMap<A, B>

Adds value at key and returns the updated map.

Link copied to clipboard
fun async(@WorkerThread block: suspend CoroutineScope.() -> Unit): () -> Unit

Runs some code asynchronously. Use uiContext for updating UI elements. This method is intended to be used for parameters that require a function in the () -> Unit form.

Link copied to clipboard
fun Int.color(): Color

Creates a new Color instance from an ARGB color int. The resulting color is in the ColorSpace.Named.SRGB color space.

Link copied to clipboard
fun List<GeoPoint>.computeCentroid(): GeoPoint

Computes the center point of all the ones in the list.

Link copied to clipboard
fun String.copy(clipboardManager: ClipboardManager, label: String = "Copied text")

Copies the String into the clipboard using ClipboardManager.

Link copied to clipboard

Crops the Bitmap into a square image.

Link copied to clipboard
fun deleteDir(dir: File?): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Removes all line jumps (\n) from the string.

Link copied to clipboard
fun dirSize(file: File): Long
Link copied to clipboard
fun disable(vararg preferences: Preference?)
Link copied to clipboard
fun GeoPoint.distanceTo(other: GeoPoint): Float

Computes the distance between two GeoPoint. Quite a dirty approach, using conversions to Location, but works as expected.

Link copied to clipboard
fun doAsync(@WorkerThread block: suspend CoroutineScope.() -> Unit): Job

Runs some code asynchronously. Use doOnMain for updating UI elements.

Link copied to clipboard
fun doOnMain(@UiThread block: suspend CoroutineScope.() -> Unit): Job

Runs some code on the UI thread.

Link copied to clipboard
fun enable(vararg preferences: Preference?)
Link copied to clipboard
Link copied to clipboard
fun getBitmapFromUri(contentResolver: ContentResolver, uri: Uri): Bitmap?

Extracts a Bitmap from an Uri.

Link copied to clipboard
fun List<GeoPoint>.getBoundingBox(): BoundingBox

Gets the BoundingBox of a list of GeoPoints. Will cause issues when called with less than 2 elements on the list.

Link copied to clipboard
fun JSONObject.getDate(key: String, defaultValue: Date? = null): Date?

Converts a date with the ISO format to a Date object.

Link copied to clipboard
inline fun <T> Activity.getExtra(key: DataExtra<T>): T?
inline fun <T> Intent.getExtra(key: DataExtra<T>): T?
inline fun <T> Bundle.getExtra(extra: DataExtra<T>): T?
inline fun <T> Activity.getExtra(key: DataExtra<T>, default: T): T
inline fun <T> Intent.getExtra(key: DataExtra<T>, default: T): T
Link copied to clipboard
inline fun <T> Activity.getExtraOrSavedInstanceState(extra: DataExtra<T>, savedInstanceState: Bundle?): T?

Gets the specified extra parameter, or if null, gets from savedInstanceState.

Link copied to clipboard
suspend fun Context.getJson(url: String, jsonRequest: JSONObject? = null): JSONObject

Makes a HTTP GET request using Volley.

Link copied to clipboard

Gets the value at the given key as a String or returns false if no value, or if null.

Link copied to clipboard
fun <T> JSONObject.getValue(key: String, defaultValue: T): T

Gets the value at key and gets casted to T, if could not be casted, or not existing returns defaultValue.

Link copied to clipboard

Checks if the JSONObject has a child key with a valid value (excluding "NULL").

Link copied to clipboard
fun humanReadableByteCountBin(bytes: Long, locale: Locale = Locale.getDefault()): String
Link copied to clipboard
suspend fun <T> ioContext(@WorkerThread block: suspend CoroutineScope.() -> T): T

Runs a block of code on the IO dispatcher.

Link copied to clipboard
Link copied to clipboard
fun Intent.launch(context: Context)

Runs Context.startActivity with this.

fun Context.launch(target: Class<*>, properties: Intent.() -> Unit? = null)

Starts an activity with the specified properties for the Intent.

fun Context.launch(intent: Intent, options: Bundle? = null, properties: Intent.() -> Unit? = null)

Launches an intent from the select context and adding some options and applying properties in a more Kotlin-like syntax.

fun Context.launch(target: Class<*>, options: Bundle, properties: Intent.() -> Unit? = null)

Starts an activity with the specified properties for the Intent, and the specified options for the launching.

Link copied to clipboard
suspend fun Intent.launchAsync(context: Context)

Runs Context.startActivity with this in the UI thread.

Link copied to clipboard

Launches the default market for the current package name, or the Google Play link if not available.

Link copied to clipboard
fun GeoPoint.mapsIntent(showMarker: Boolean = true, markerTitle: String? = null): Intent

Creates an Intent for launching Google Maps app showing the GeoPoint specified.

Link copied to clipboard

Checks if the device is compatible with MD5 file hashing.

Link copied to clipboard
fun <T> Bundle.put(extra: DataExtra<T>, value: T)
Link copied to clipboard
fun <T> Intent.putExtra(key: DataExtra<T>, value: T): Intent
Link copied to clipboard

Returns the fragment's Activity as an AppCompatActivity and makes sure it's non-null.

Link copied to clipboard
fun Bitmap.resize(width: Int, height: Int): Bitmap

Resizes the Bitmap to the selected size.

Link copied to clipboard
fun Context.resourceUri(resourceId: Int): Uri

Gets a resource's Uri.

Link copied to clipboard
fun Bitmap.scale(scale: Float): Bitmap

Scales a Bitmap to the desired scale.

Link copied to clipboard
fun Context.share(text: String)

Shares text through the system UI.

Link copied to clipboard
fun File.size(): Long
Link copied to clipboard

Returns the size in bytes of the Bundle.

Link copied to clipboard
fun <R> Boolean.then(call: () -> R): R?

Calls call only if the class is true.

Link copied to clipboard
fun <R> Boolean.thenComp(call: @Composable () -> R): R?

Calls call only if the class is true. Used for composable calls

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

Tints the Drawable with the set color.

Link copied to clipboard
fun toast(context: Context?, @StringRes text: Int): Unit?
fun toast(context: Context?, text: String): Unit?
fun Context.toast(@StringRes text: Int, duration: Int = Toast.LENGTH_SHORT)
fun Context.toast(text: String, duration: Int = Toast.LENGTH_SHORT)
fun toast(context: Context?, @StringRes text: Int, vararg args: Any): Unit?
Link copied to clipboard
fun Location.toGeoPoint(): GeoPoint
Link copied to clipboard

Converts the ValueMax to a Int-based one, using the ValueMax.percentage function.

Link copied to clipboard
fun GeoPoint.toLocation(): Location

Converts a GeoPoint object into a Location.

Link copied to clipboard

Converts the Bundle's contents into a map.

Link copied to clipboard
fun GeoPoint.toUri(showMarker: Boolean = false, markerTitle: String? = null): Uri
Link copied to clipboard
suspend fun <T> uiContext(@UiThread block: suspend CoroutineScope.() -> T): T
suspend fun <T, A : Activity> A.uiContext(@UiThread block: suspend A.() -> T): T

Runs a block of code on the main dispatcher (UI thread).

Link copied to clipboard
suspend fun <T, R> T.uiLet(block: suspend (T) -> R): R

Runs the block at block with the UI context.

Link copied to clipboard
fun Context.vibrate(duration: Long)

Makes the device vibrate for duration milliseconds.

Properties

Link copied to clipboard

Returns the fragment's Activity as an AppCompatActivity with null-check.

Link copied to clipboard
val asyncCoroutineScope: CoroutineScope

The CoroutineScope used in functions such as doAsync.

Link copied to clipboard
Link copied to clipboard
val mainCoroutineScope: CoroutineScope

The CoroutineScope used in functions such as doOnMain.

Link copied to clipboard
const val MBYTE: Int

Specifies the size in bytes of a megabyte.

Link copied to clipboard
const val MEGABYTE: Long

Specifies the size in bytes of a megabyte.

Link copied to clipboard
val Dp.px: Float

Converts the Dp value into Px.

Link copied to clipboard

Tries to use the WEB_LOSSLESS codec, if API level is less than R, uses WEBP

Link copied to clipboard

Tries to use the WEBP_LOSSY codec, if API level is less than R, uses WEBP