Skip to content

Instantly share code, notes, and snippets.

@nikhilbansal97
Created June 27, 2018 07:29
Show Gist options
  • Save nikhilbansal97/19a08ee63feeb95826d0fdeefc15592f to your computer and use it in GitHub Desktop.
Save nikhilbansal97/19a08ee63feeb95826d0fdeefc15592f to your computer and use it in GitHub Desktop.
The MainActivity for the view layer of the SampleMVP project
package com.example.nikhil.samplemvp.view
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.example.nikhil.samplemvp.presenter.MainActivityPresenter
import com.example.nikhil.samplemvp.R
import com.example.nikhil.samplemvp.contract.ContractInterface.*
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity(), View {
private var presenter: MainActivityPresenter? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
presenter = MainActivityPresenter(this)
}
override fun initView() {
counterTextView.text = presenter?.getCounter()
clickButton.setOnClickListener { presenter?.incrementValue() }
}
override fun updateViewData() {
counterTextView.text = presenter?.getCounter()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment