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

import android.arch.lifecycle.Observer
import android.arch.lifecycle.ViewModelProviders
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.di.Injectable

/**
 * タスク追加のActivity
 * Created by matsumoto_k on 2018/03/06.
 */
class AddEditTaskActivity : BaseActivity(), HasSupportFragmentInjector, Injectable {

    lateinit var addEditTaskViewModel: AddEditTaskViewModel

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_add_edit_task)
        addEditTaskViewModel = ViewModelProviders.of(this, viewModelFactory).get(AddEditTaskViewModel::class.java)
        subscribe()
    }

    fun subscribe() {
        addEditTaskViewModel.taskAddEvent.observe(this, Observer {
            finish()
        })
    }

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