oak.viewmodel
Class ViewModelUtil

java.lang.Object
  extended by oak.viewmodel.ViewModelUtil

public class ViewModelUtil
extends Object

Created by ericrichardson on 1/9/14.


Method Summary
static
<T> ViewModel<T>
getViewModel(android.view.LayoutInflater inflater, int layoutId, android.view.View convertView, android.view.ViewGroup parent)
          A utility function for getting a ViewModel out of a view in an adapter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getViewModel

public static <T> ViewModel<T> getViewModel(android.view.LayoutInflater inflater,
                                            int layoutId,
                                            android.view.View convertView,
                                            android.view.ViewGroup parent)
A utility function for getting a ViewModel out of a view in an adapter. If convertView is null, the view is inflated, otherwise convertView is returned. (The view to inflate must implement ViewModel).

A standard implementation would call this, populate the ViewModel, then return it.

     ViewModel<T> view = getViewModel(inflater, layoutId, convertView, parent);
     view.populate(getItem(position));
     return (View) view;
 

Type Parameters:
T - the type of item in the ViewModel
Parameters:
inflater - the view inflater
layoutId - the layout to inflate
convertView - the convertView from adapter.getView()
parent - the parent from adapter.getView()
Returns:
the ViewModel


Copyright © 2011-2014. All Rights Reserved.