Newer
Older
DevAndroid / app / src / main / java / keijumt / devandroid / fragment / MainFragment.kt
package keijumt.devandroid.fragment


import android.arch.lifecycle.ViewModelProviders
import android.databinding.DataBindingUtil
import android.os.Bundle
import android.support.v4.app.FragmentActivity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import keijumt.devandroid.R
import keijumt.devandroid.databinding.FragmentMainBinding
import keijumt.devandroid.viewmodel.MainViewModel

class MainFragment : BaseFragment() {

    lateinit var binding: FragmentMainBinding
    lateinit var mainViewModel: MainViewModel


    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
                              savedInstanceState: Bundle?): View? {
        val nonNullActivity: FragmentActivity = activity ?: return null
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_main, null, false)
        mainViewModel = ViewModelProviders.of(nonNullActivity, viewModelFactory).get(MainViewModel::class.java)
        binding.mainViewModel = mainViewModel
        return binding.root
    }


}