in sample/src/main/kotlin/autodispose2/sample/DisposingViewModelActivity.kt [43:63]
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_disposing_viewmodel)
textView = findViewById(R.id.textView)
progressBar = findViewById(R.id.downloadProgress)
progressBar.max = 50
// If we're coming from a configuration change, no need to
// start the stream again.
if (savedInstanceState == null) {
viewModel.downloadLargeImage()
}
// Get latest value from ViewModel unaffected by any config changes.
viewModel
.downloadState()
.observeOn(AndroidSchedulers.mainThread())
.autoDispose(scope)
.subscribe({ state -> resolveState(state) }, {})
}