Skip to content

Instantly share code, notes, and snippets.

@SeongUgJung
Last active August 26, 2018 15:26
Show Gist options
  • Save SeongUgJung/e92ebb78d20348e67b05d542026853b8 to your computer and use it in GitHub Desktop.
Save SeongUgJung/e92ebb78d20348e67b05d542026853b8 to your computer and use it in GitHub Desktop.
resource provider
class MainViewModel(private val resourcesProvider: ResourcesProvider) {
val name = ObservableField()
fun click() {
name.set(resourceProvider.getString(R.string.name_title))
}
}
interface ResourcesProvider {
fun getString(resId:String) : CharSequence
}
class ResourcesProviderImpl(private val context:Context) : ResourcesProvider {
fun getString(resId) = context.getString(resId)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment