Last active
August 26, 2018 15:26
-
-
Save SeongUgJung/e92ebb78d20348e67b05d542026853b8 to your computer and use it in GitHub Desktop.
resource provider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainViewModel(private val resourcesProvider: ResourcesProvider) { | |
val name = ObservableField() | |
fun click() { | |
name.set(resourceProvider.getString(R.string.name_title)) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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