Skip to content

Resources

findByContext

Version 0.5.2

findByContext provides you with Context so that you can find the resources.

val drawable = findByContext {
    AppCompatResources.getDrawable(this, R.drawable.android_logo)
}
try {
    drawable = ResUtilsKt.findByContext(context ->
        AppCompatResources.getDrawable(context, R.drawable.android_logo)
    );
} catch (Exception e) {
    throw new RuntimeException(e);
}

findByResources

Version 0.5.2

findByResources provides you with Resources so that you can find the resources.

val drawable = findByResources { res, theme ->
    ResourcesCompat.getDrawable(res, R.drawable.android_logo, theme)
}
try {
    drawable = ResUtilsKt.findByResources((resources, theme) ->
        ResourcesCompat.getDrawable(resources, R.drawable.android_logo, theme)
    );
} catch (Exception e) {
    throw new RuntimeException(e);
}