com.operators.swipes
Class SwipesAdapter<T>

java.lang.Object
  extended by android.widget.BaseAdapter
      extended by com.operators.swipes.SwipesAdapter<T>
All Implemented Interfaces:
Adapter, ListAdapter, SpinnerAdapter

public abstract class SwipesAdapter<T>
extends BaseAdapter

This class is a common base class for data containment, made specifically for SwipesView.

The following is a basic implementation of SwipesAdapter:


class BasicExampleSwipesAdapter extends SwipesAdapter<Integer>{
  ArrayList<Integer> mInts = new ArrayList<Integer>(Arrays.asList(new Integer[]{
    1, 11, 111
  }));
  public BasicExampleSwipesAdapter(Context context, int resource) {
    super(context, resource);
  }
  @Override public View getView (int position, View convertView, ViewGroup parent) {
        View inflatedResource = super.getView(position, convertView, parent);
        TextView card_text = (TextView) inflatedResource.findViewById(R.id.card_text);
        card_text.setText(getItem(position).toString());
        return inflatedResource;
  }
  @Override public Integer getItem(int position) { return mInts.get(position); }
  @Override public void removeItem(int position) { mInts.remove(position); }
  @Override public int getCount() { return mInts.size(); }
}
  
The BasicExampleSwipesAdapter should be passed to the SwipesView.setAdapter(SwipesAdapter):
  SwipesView sv = new SwipesView(context);
  sv.setAdapter(new BasicExampleSwipesAdapter(context, R.layout.card_item));
  


Field Summary
 
Fields inherited from interface android.widget.Adapter
IGNORE_ITEM_VIEW_TYPE, NO_SELECTION
 
Constructor Summary
SwipesAdapter(Context context, int resource)
          Constructs the Swipes Adapter in Java source code.
 
Method Summary
 long getItemId(int position)
          Overrides parent implementation of getItemId.
 View getView(int position, View convertView, ViewGroup parent)
          Sets up the passed in resource (with a LayoutInflator).
abstract  void removeItem(int position)
          Is called after a card is removed from the view hierarchy at the passed position.
 
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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface android.widget.Adapter
getCount, getItem
 

Constructor Detail

SwipesAdapter

public SwipesAdapter(Context context,
                     int resource)
Constructs the Swipes Adapter in Java source code.

Parameters:
context - The activity context use for creation.
resource - The resource/layout inflated from android xml.
Method Detail

removeItem

public abstract void removeItem(int position)
Is called after a card is removed from the view hierarchy at the passed position.

Parameters:
position - The passed position of the item to be removed.

getItemId

public long getItemId(int position)
Overrides parent implementation of getItemId.

Parameters:
position - The passed position of the item to be accessed.

getView

public View getView(int position,
                    View convertView,
                    ViewGroup parent)
Sets up the passed in resource (with a LayoutInflator).

Parameters:
position - The passed position of the item to be accessed.
convertView - The passed view that will be inflated, or was previously.
parent - The parent that this view will eventually be attached to, if not already.