RichUtils / pyxis.uzuki.live.richutilskt.utils

Package pyxis.uzuki.live.richutilskt.utils

Types

ContactItem

data class ContactItem

Intensity

enum class Intensity

RPermission

class RPermission

RPickMedia

class RPickMedia

RPreference

class RPreference

ResizeMode

enum class ResizeMode

Extensions for External Classes

android.app.Activity

android.app.Application

android.app.Dialog

android.content.Context

android.content.res.AssetManager

android.graphics.Bitmap

android.net.Uri

android.os.Bundle

android.view.ViewGroup

java.io.File

java.io.InputStream

java.util.Date

kotlin.Long

kotlin.String

kotlin.collections.List

kotlin.collections.Map

org.json.JSONArray

org.json.JSONObject

Functions

allContains

fun allContains(target: String, vararg items: String): Boolean

Test target contains all condition of items

allEmpty

fun allEmpty(vararg target: String): Boolean

Test all element of target is empty

allEquals

fun allEquals(target: String, vararg items: String): Boolean

Test target equals all condition of items

allNotEmpty

fun allNotEmpty(vararg target: String): Boolean

Test all element of target is not empty

anyContains

fun anyContains(target: String, vararg items: String): Boolean

Test target contains any condition of items

anyContainsString

fun anyContainsString(inputStr: String, items: Array<String>): Boolean
fun anyContainsString(inputStr: String, items: List<String>): Boolean

Returns true if at least one element matches condition of contains string

anyEmpty

fun anyEmpty(vararg target: String): Boolean

Test any element of target is empty

anyEquals

fun anyEquals(target: String, vararg items: String): Boolean

Test target equals any condition of items

anyMatchRegex

fun anyMatchRegex(regex: String, items: Array<String>): Boolean
fun anyMatchRegex(regex: String, items: List<String>): Boolean

Returns true if at least one element matches condition of matches regex

anyNotEmpty

fun anyNotEmpty(vararg target: String): Boolean

Test any element of target is not empty

downloadBitmap

fun downloadBitmap(imageUrl: String): Bitmap?

Download bitmap from uri

downloadFile

fun downloadFile(urlPath: String, localPath: String, callback: (Uri?) -> Unit = {}): Uri?
fun downloadFile(urlPath: String, localPath: String, callback: F1<Uri>?): Uri?

Download file from uri

drawableToBitmap

fun drawableToBitmap(drawable: Drawable): Bitmap

Convert Drawable to Bitmap in safe way

generateViewId

fun generateViewId(): Int

Generate View ID

getJSONArray

fun getJSONArray(jsonObject: JSONObject?, name: String): JSONArray?

get JSONArray from JSONObject

fun getJSONArray(jsonArray: JSONArray?, index: Int): JSONArray?

get JSONArray from JSONArray

getJSONObject

fun getJSONObject(jsonObject: JSONObject?, name: String): JSONObject?

get JSONObject from JSONObject

fun getJSONObject(jsonArray: JSONArray?, index: Int): JSONObject?

get JSONObject from JSONArray

getPhotoHeight

fun getPhotoHeight(filePath: String?): Int

get height of photo from ExifInterface

getPhotoOrientationDegree

fun getPhotoOrientationDegree(filePath: String?): Int

get orientation degree of photo from ExifInterface

getPhotoWidth

fun getPhotoWidth(filePath: String?): Int

get width of photo from ExifInterface

getUri

fun getUri(file: File?): Uri?

Convert File into Uri.

getVibratorPattern

fun getVibratorPattern(intensity: Intensity, duration: Long): LongArray

get Intensity (Desired Strength) of Vibrate NOTE: Some device's default value may 0.7f (Tested in Galaxy S6),

fun getVibratorPattern(intensity: Float, duration: Long): LongArray

get Intensity (Desired Strength) of Vibrate Normal Way, just use getVibratorPattern(Intensity, long) for easy work.

isMediaUri

fun isMediaUri(uri: Uri?): Boolean

check uri is media uri

put

fun put(map: Map<String, Any>): Bundle

return Bundle which contain contents of Map<String, Any>

fun put(jsonObject: JSONObject?, name: String, value: Any): JSONObject?

put value to JSONObject

fun put(jsonArray: JSONArray?, index: Int, value: Any): JSONArray?

put value to JSONArray

fun put(jsonArray: JSONArray?, value: Any): JSONArray?

put value to JSONArray without ordering

rotate

fun rotate(bitmap: Bitmap, degree: Int): Bitmap

rotate bitmap

runAsync

fun runAsync(poolSize: Int = RAsync.instance.settingPoolSize, action: () -> Unit): Unit
fun runAsync(poolSize: Int = RAsync.instance.settingPoolSize, action: F0): Unit

run code inside of Background thread with custom pool size this will help in multi-threading working

fun runAsync(action: () -> Unit): Unit
fun runAsync(action: F0): Unit

run code inside of Background thread with default pool size this will help in multi-threading working

runDelayed

fun runDelayed(delayMillis: Long, action: () -> Unit): Boolean
fun runDelayed(delayMillis: Long, action: F0): Boolean

run code inside of Background Thread after given delay

runDelayedOnUiThread

fun runDelayedOnUiThread(action: () -> Unit, delayMillis: Long): Boolean
fun runDelayedOnUiThread(action: F0, delayMillis: Long): Boolean

run code inside of UI Thread after given delay

runOnUiThread

fun runOnUiThread(action: () -> Unit): Boolean
fun runOnUiThread(action: F0): Boolean

run code inside of UI Thread

saveFile

fun saveFile(fullPath: String, content: String): File

save file with content

toNumFormat

fun toNumFormat(num: String): String

formatting number like 1,000,000

tryCatch

fun <T, R> T.tryCatch(block: (T) -> R): R
fun tryCatch(block: F0): Unit