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