diff --git a/app/src/main/java/keijumt/todoapp/MainActivity.kt b/app/src/main/java/keijumt/todoapp/MainActivity.kt index 82cf3bd..6476b18 100644 --- a/app/src/main/java/keijumt/todoapp/MainActivity.kt +++ b/app/src/main/java/keijumt/todoapp/MainActivity.kt @@ -1,17 +1,30 @@ package keijumt.todoapp +import android.arch.lifecycle.ViewModelProviders +import android.databinding.DataBindingUtil import android.os.Bundle import android.support.v4.app.Fragment import dagger.android.AndroidInjector import dagger.android.support.HasSupportFragmentInjector import keijumt.todoapp.activity.BaseActivity +import keijumt.todoapp.databinding.ActivityMainBinding import keijumt.todoapp.di.Injectable +import keijumt.todoapp.viewmodel.MainViewModel +/** + * メイン画面のActivity + * Created by matsumoto_k on 2018/03/06. + */ class MainActivity : BaseActivity(), HasSupportFragmentInjector, Injectable { + lateinit var binding: ActivityMainBinding + lateinit var mainViewModel: MainViewModel + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) + binding = DataBindingUtil.setContentView(this, R.layout.activity_main) + mainViewModel = ViewModelProviders.of(this, viewModelFactory).get(MainViewModel::class.java) + lifecycle.addObserver(mainViewModel) } override fun supportFragmentInjector(): AndroidInjector {