-
Notifications
You must be signed in to change notification settings - Fork 0
ResourceUtils
-
stringRes(@StringRes stringId: Int, context: Context = appCtx)
Returns string from the provided string id. LikeR.string.<stringID>
-
getFormattedString(format: String, vararg objects: Any):String
Return formatted string by giving string format and multiple arguments. -
getFormattedString(stringId: Int, vararg objects: Any, context: Context = appCtx):String
Return formatted string with string id and multiple arguments. -
drawableRes(@DrawableRes drawableId: Int, context: Context = appCtx):Drawable
Return drawable with drawable id from resources folder. LikeR.drawable.<drawableID>
-
drawableByName(drawableNameWithoutExtension: String, context: Context = appCtx): Drawable?
Return drawable from the name of the drawble in resources, but without extension. -
colorRes(@ColorRes colorId: Int, context: Context = appCtx):Int
Return int color from resources.Like R.color.<colorID>
-
bitmapFromDrawableRes(@DrawableRes drawableId: Int, context: Context = appCtx): Bitmap?
Return bitmap from provided drawable id from resources folder.LikeR.drawable.<drawableID>
-
animRes(@AnimRes animId: Int, context: Context = appCtx): Animation
Return animation from anim resources in android. LikeR.anim.<animationID>
-
fontRes(@FontRes fontId: Int, context: Context = appCtx)
Return font from resources font folder. LikeR.font.<fontResourceID>
-
dimen(@DimenRes dimenId: Int, context: Context = appCtx)
Return dimen from dimens resources. LikeR.dimen.<dimen resource>
. -
integerRes(@IntegerRes dimenIntId: Int, context: Context = appCtx):Int
Return dimen integer from dimens. LikeR.integer.<dimen integer dimenIntID>
-
intArray(@ArrayRes dimenArrayIntId: Int, context: Context = appCtx):Array<Int>
Return int array from dimens. LikeR.array.<dimen arrayID>
-
stringArray(@ArrayRes dimenArrayStringId: Int, context: Context = appCtx): Array<String>
Return string array from dimens. LikeR.array.<dimen stringArrayID>
-
getScreenWidth(): Int>
Return width of your android screen -
getScreenHeight(): Int>
Return height of your android screen
Note: All the above method requires
ApplicationContext
, which is provided by default. However, in case of theme and context switching.Context
is must required after theme or context change. All of them are basically resource pickers, like we writeR.string.<string resource>
,R.drawable.<drawable resource>
and so on.