Skip to content

Commit

Permalink
Merge pull request #111 from KakaoCup/feat-string-resources-uplift
Browse files Browse the repository at this point in the history
feat(utilities): add plurals and varargs strings support
  • Loading branch information
Vacxe authored Jan 5, 2024
2 parents 0fe04fc + b7d0ca4 commit 44b7be9
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@ package io.github.kakaocup.kakao.common.utilities

import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.PluralsRes
import androidx.annotation.StringRes
import androidx.core.content.ContextCompat
import androidx.test.platform.app.InstrumentationRegistry

fun getResourceString(@StringRes resId: Int) = InstrumentationRegistry.getInstrumentation().targetContext.resources.getString(resId)
fun getResourceString(@StringRes resId: Int) =
InstrumentationRegistry.getInstrumentation().targetContext.resources.getString(resId)

fun getResourceString(@StringRes resId: Int, vararg args: Any) =
InstrumentationRegistry.getInstrumentation().targetContext.resources.getString(resId, args)

fun getQuantityString(@PluralsRes resId: Int, quantity: Int) =
InstrumentationRegistry.getInstrumentation().targetContext.resources.getQuantityString(resId, quantity)

fun getResourceDrawable(@DrawableRes resId: Int) =
ContextCompat.getDrawable(InstrumentationRegistry.getInstrumentation().targetContext, resId)

fun getResourceColor(@ColorRes resId: Int) = ContextCompat.getColor(InstrumentationRegistry.getInstrumentation().targetContext, resId)
fun getResourceColor(@ColorRes resId: Int) =
ContextCompat.getColor(InstrumentationRegistry.getInstrumentation().targetContext, resId)

0 comments on commit 44b7be9

Please sign in to comment.