Newer
Older
MonCalc / app / src / main / kotlin / jackall / moncalc / activity / MainActivity.kt
package jackall.moncalc.activity

import android.arch.lifecycle.ViewModelProviders
import android.databinding.DataBindingUtil
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import jackall.moncalc.R
import jackall.moncalc.databinding.ActivityMainBinding
import jackall.moncalc.viewmodel.MainViewModel

/**
 * Created by matsumoto_k on 2017/11/03.
 */
class MainActivity : AppCompatActivity() {
    val mainBinding by lazy { DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main) }
    val mainViewModel by lazy { ViewModelProviders.of(this, MainViewModel.Factory()).get(MainViewModel::class.java) }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mainBinding.mainViewModel = mainViewModel
        lifecycle.addObserver(mainViewModel)
    }
}