Back to project page GreenGear.
The source code is released under:
MIT License
If you think the Android project GreenGear listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.bradleycurran.velocadapter; /*www . j a va2 s. com*/ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import android.content.Context; public abstract class ArrayVelocAdapter<T> extends VelocAdapter { private List<T> mList; public ArrayVelocAdapter(Context context) { super(context); mList = new ArrayList<T>(); } public ArrayVelocAdapter(Context context, List<T> list) { super(context); mList = list; } @Override public int getCount() { return mList.size(); } @Override public T getItem(int position) { return mList.get(position); } public void add(T object) { mList.add(object); notifyDataSetChanged(); } public void addAll(Collection<? extends T> collection) { mList.addAll(collection); notifyDataSetChanged(); } public void addAll(T... items) { Collections.addAll(mList, items); notifyDataSetChanged(); } public void insert(T object, int index) { mList.add(index, object); notifyDataSetChanged(); } public void setList(List<T> list) { mList = list; notifyDataSetChanged(); } public void remove(T object) { mList.remove(object); notifyDataSetChanged(); } public void clear() { mList.clear(); notifyDataSetChanged(); } }