Package com.github.ushiosan23.android_utilities.extensions

Functions

attachPopupMenu
Link copied to clipboard
fun View.attachPopupMenu(ctx: Context, @MenuRes() menuId: Int, gravity: Int? = null, @AttrRes() popupStyleAttr: Int? = null, @StyleRes() style: Int? = null): PopupMenu
Set view popup menu
attachTooltip
Link copied to clipboard
fun View.attachTooltip(data: CharSequence)
Set view tooltip
fun View.attachTooltip(ctx: Context, @StringRes() resId: Int, vararg format: Any?)
Set view tooltip
changeActivity
Link copied to clipboard
inline fun <T> Activity.changeActivity(bundle: Bundle? = null, vararg extra: Pair<String, Any?>)
Change activity extension.
changeActivityAndClose
Link copied to clipboard
inline fun <T> Activity.changeActivityAndClose(bundle: Bundle? = null, vararg extra: Pair<String, Any?>)
Change activity extension.
changeActivityForResult
Link copied to clipboard
inline fun <T> Activity.changeActivityForResult(requestCode: Int, bundle: Bundle? = null, vararg extra: Pair<String, Any?>)
Change activity and wait for result.
format
Link copied to clipboard
fun CharSequence.format(vararg args: Any?): String
Apply to any text valid format
ftoDIP
Link copied to clipboard
fun Number.ftoDIP(metrics: DisplayMetrics): Float
Convert any number to DPI.
ftoSP
Link copied to clipboard
fun Number.ftoSP(metrics: DisplayMetrics): Float
Convert any number to SP.
getActivityViewRoot
Link copied to clipboard
fun <T : Activity> T.getActivityViewRoot(): View
Get activity view root.
getDisplayMetrics
Link copied to clipboard
fun <T : Context> T.getDisplayMetrics(): DisplayMetrics
Get context display metrics.
makeSnack
Link copied to clipboard
fun <T : Activity> T.makeSnack(text: CharSequence, duration: Int): Snackbar
Make activity snackbar.
fun <T : Activity> T.makeSnack(@StringRes() resId: Int, duration: Int): Snackbar
Make activity snackbar.
fun View.makeSnack(text: CharSequence, duration: Int): Snackbar
Make view snackbar.
fun View.makeSnack(@StringRes() resId: Int, duration: Int): Snackbar
Make view snackbar.
makeToast
Link copied to clipboard
fun <T : Context> T.makeToast(text: CharSequence, duration: Int): Toast
Make activity toast.
fun <T : Context> T.makeToast(@StringRes() resId: Int, duration: Int): Toast
Make context toast.
putAnyExtra
Link copied to clipboard
fun Intent.putAnyExtra(pair: Pair<String, Any?>): Intent
Extension used to put all valid intent objects.
fun Intent.putAnyExtra(name: String, value: Any?): Intent
Extension used to put all valid intent objects.
resolveClass
Link copied to clipboard
inline fun <T, V> T.resolveClass(): Class<V>
Return any object java class
toComplexDimension
Link copied to clipboard
fun Number.toComplexDimension(metrics: DisplayMetrics, dimension: Int): Number
Convert any number to complex value dimension.
toDIP
Link copied to clipboard
fun Number.toDIP(metrics: DisplayMetrics): Number
Convert any number to DPI.
toInfoString
Link copied to clipboard
fun Any.toInfoString(): String
Object string representation
toShortInfoString
Link copied to clipboard
fun Any.toShortInfoString(): String
Object string representation
toSP
Link copied to clipboard
fun Number.toSP(metrics: DisplayMetrics): Number
Convert any number to SP.
tryCast
Link copied to clipboard
inline fun <V> Any.tryCast(action: (V) -> Unit): Any
Try to cast object to another type
tryCastContext
Link copied to clipboard
inline fun <V> Any.tryCastContext(action: V.() -> Unit): Any
Try to cast object to another type

Properties

connectivityManager
Link copied to clipboard
val Context.connectivityManager: ConnectivityManager
Get connectivity manager
sharedPreferences
Link copied to clipboard
val Context.sharedPreferences: SharedPreferences
Get application shared preferences