Skip to content

Instantly share code, notes, and snippets.

@paulocns
Last active August 4, 2018 22:15
Show Gist options
  • Select an option

  • Save paulocns/76e7c2a3069f59de06205d302107c8e1 to your computer and use it in GitHub Desktop.

Select an option

Save paulocns/76e7c2a3069f59de06205d302107c8e1 to your computer and use it in GitHub Desktop.
class QueryFragment : BaseFragment() {
private var binding: FragmentQueryMvvmBinding? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_query_mvvm, container, false)
binding = DataBindingUtil.bind(view)
return view
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val queryViewModelArc = ViewModelProviders.of(this, viewModelFactory).get(QueryViewModelArc::class.java)
binding?.let{
it.viewModel = queryViewModelArc
it.setLifecycleOwner(this)
it.executePendingBindings()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment