oak.viewmodel
Class ViewModelAdapter<T>

java.lang.Object
  extended by android.widget.BaseAdapter
      extended by oak.viewmodel.ViewModelAdapter<T>
All Implemented Interfaces:
android.widget.Adapter, android.widget.ListAdapter, android.widget.SpinnerAdapter

public class ViewModelAdapter<T>
extends android.widget.BaseAdapter

User: evantatarka Date: 9/25/13 Time: 4:31 PM

A basic adapter that follows the ViewModel pattern. If you only need to show a list of homogeneous items you should use or subclass this. The layout that you pass must be a custom ViewGroup that implements ViewModel<T>.


Field Summary
 
Fields inherited from interface android.widget.Adapter
IGNORE_ITEM_VIEW_TYPE, NO_SELECTION
 
Constructor Summary
ViewModelAdapter(android.content.Context context, int layoutId, List<T> items)
          Constructs a new ViewModelAdapter with the given layout and items.
 
Method Summary
protected  android.content.Context getContext()
           
 int getCount()
           
 T getItem(int i)
           
 long getItemId(int i)
           
 List<T> getItems()
          Returns the backing list.
 android.view.View getView(int i, android.view.View convertView, android.view.ViewGroup parent)
           
 void replace(List<T> items)
           
 
Methods inherited from class android.widget.BaseAdapter
areAllItemsEnabled, getDropDownView, getItemViewType, getViewTypeCount, hasStableIds, isEmpty, isEnabled, notifyDataSetChanged, notifyDataSetInvalidated, registerDataSetObserver, unregisterDataSetObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewModelAdapter

public ViewModelAdapter(android.content.Context context,
                        int layoutId,
                        List<T> items)
Constructs a new ViewModelAdapter with the given layout and items. The layout must implement ViewModel<T> as is expected to hold the logic of updating its children.

Note that this class does not make a copy of the list you pass in. You can modify the original list and call notifyDataSetChanged() to update the view.

Parameters:
context - the context
layoutId - the layout to inflate
items - the list of items to show
Method Detail

getCount

public int getCount()

getItem

public T getItem(int i)

getItemId

public long getItemId(int i)

getView

public android.view.View getView(int i,
                                 android.view.View convertView,
                                 android.view.ViewGroup parent)

getItems

public List<T> getItems()
Returns the backing list. This is the same one that is passed into the constructor.

Returns:
the list of items

replace

public void replace(List<T> items)

getContext

protected android.content.Context getContext()


Copyright © 2011-2014. All Rights Reserved.