Newer
Older
ToDoApp / app / src / main / java / keijumt / todoapp / main / MainActivity.kt
package keijumt.todoapp.main

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.BaseActivity
import keijumt.todoapp.R
import keijumt.todoapp.databinding.ActivityMainBinding
import keijumt.todoapp.di.Injectable

/**
 * メイン画面の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)
        binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
        mainViewModel = ViewModelProviders.of(this, viewModelFactory).get(MainViewModel::class.java)
        lifecycle.addObserver(mainViewModel)
    }

    override fun supportFragmentInjector(): AndroidInjector<Fragment> {
        return androidInjector
    }
}