Skip to content

Instantly share code, notes, and snippets.

@surajsau
Created July 18, 2019 11:12
Show Gist options
  • Save surajsau/f1176fce5a14161a2b5acfec0032b6a4 to your computer and use it in GitHub Desktop.
Save surajsau/f1176fce5a14161a2b5acfec0032b6a4 to your computer and use it in GitHub Desktop.
MVP to MVVM: MainActivity
class MainActivity : AppCompatActivity(), MainView {
val presenter: MainPresenter by currentScope.inject()
val adapter: ResultAdapter by currentScope.inject()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//using koin, so had to provide view this way
presenter.view = this
fab.setOnClickListener { presenter.onFabClick() }
.
.
presenter.search("kotlin")
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onResultFavoriteClickReceive(message: ResultFavoriteMessage){
presenter.onResultFavoriteClickReceive(message)
}
override fun onStart() {..}
override fun onStop() {..}
override fun showProgress() {
progress_circular.visibility = View.VISIBLE
}
override fun hideProgress() {..}
override fun showError() {..}
override fun hideError() {..}
override fun setItems(items: List<com.halfplatepoha.psuedomvvm.models.Repo>?) {
adapter.items = items
}
override fun openRepositoryDetails(repo: String?, owner: String?) {
startActivity(DetailsActivity.getNewIntent(this, repo, owner))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment