Skip to content

Instantly share code, notes, and snippets.

@vamsitallapudi
Created December 13, 2020 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vamsitallapudi/af68d62b84f4bac9a9e01a93c2f392c6 to your computer and use it in GitHub Desktop.
Save vamsitallapudi/af68d62b84f4bac9a9e01a93c2f392c6 to your computer and use it in GitHub Desktop.
class PrefActivity : AppCompatActivity() {
lateinit var viewModelFactory: PrefViewModelFactory
private val btnDarkMode: Button = Button(this)
private lateinit var viewmodel: PrefViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_pref)
viewModelFactory = PrefViewModelFactory((application as DIExampleApp).repository)
viewmodel= ViewModelProvider(this, viewModelFactory).get(PrefViewModel::class.java)
btnDarkMode.setOnClickListener {
viewmodel.updateDarkMode(true)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment