Created
July 21, 2021 13:22
-
-
Save aasierra/10b46892e4e16fd4b78162b3a41a95b6 to your computer and use it in GitHub Desktop.
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 MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
// Create the binding and set it as the content view. | |
val binding = ActivityMainBinding.inflate(layoutInflater) | |
setContentView(binding.root) | |
// Create view model that normally would be created in an injection system such as | |
// by viewModel, or Dagger, or Hilt. | |
// For our purposes of discussion we are just instantiating here as it does not matter | |
// where our BusinessLogicCenter (ViewModel) comes from. | |
val viewModel = ProductInfoBusinessLogicCenterViewModel() | |
viewModel.productInfo.observe(this, { displayObject -> | |
// Now we simply just set the display object! | |
binding.displayObject = displayObject | |
binding.executePendingBindings() | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment