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.FragmentApiBinding import keijumt.devandroid.viewmodel.ApiViewModel class ApiFragment : BaseFragment() { lateinit var binding: FragmentApiBinding lateinit var mainViewModel: ApiViewModel override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val nonNullActivity: FragmentActivity = activity ?: return null binding = DataBindingUtil.inflate(inflater, R.layout.fragment_api, null, false) mainViewModel = ViewModelProviders.of(nonNullActivity, viewModelFactory).get(ApiViewModel::class.java) binding.mainViewModel = mainViewModel return binding.root } }