Skip to content

Instantly share code, notes, and snippets.

@myeonginwoo
Created November 4, 2018 17:19
Show Gist options
  • Save myeonginwoo/b0ca29ae7d2d26a38900c650b2f22a34 to your computer and use it in GitHub Desktop.
Save myeonginwoo/b0ca29ae7d2d26a38900c650b2f22a34 to your computer and use it in GitHub Desktop.
class MainActivity : AppCompatActivity(), MainView {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val mainViewModel = MainViewModel(this, DataStore())
bt_a.setOnClickListener {
mainViewModel.requestItemInfo(ItemType.ITEM_A)
}
bt_b.setOnClickListener {
mainViewModel.requestItemInfo(ItemType.ITEM_B)
}
bt_c.setOnClickListener {
mainViewModel.requestItemInfo(ItemType.ITEM_C)
}
}
override fun onUpdatedItem(oldItem: Item, newItem: Item) {
tv_item.text = "${oldItem.title} -> ${newItem.title}"
iv_item.setBackgroundColor(Color.parseColor(newItem.color))
}
override fun showProgress() {
pb_item.show()
}
override fun hideProgress() {
pb_item.hide()
}
override fun onError(throwable: Throwable?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment