com.github.ignition.core.adapters
Class EndlessListAdapter<T>
java.lang.Object
android.widget.BaseAdapter
com.github.ignition.core.adapters.EndlessListAdapter<T>
- All Implemented Interfaces:
- android.widget.Adapter, android.widget.ListAdapter, android.widget.SpinnerAdapter
public abstract class EndlessListAdapter<T>
- extends android.widget.BaseAdapter
Fields inherited from interface android.widget.Adapter |
IGNORE_ITEM_VIEW_TYPE, NO_SELECTION |
Constructor Summary |
EndlessListAdapter(android.app.Activity activity,
android.widget.AbsListView listView,
int progressItemLayoutResId)
|
EndlessListAdapter(android.app.ExpandableListActivity activity,
int progressItemLayoutResId)
|
EndlessListAdapter(android.app.ListActivity activity,
int progressItemLayoutResId)
|
Method Summary |
void |
addAll(List<T> items)
|
void |
addAll(List<T> items,
boolean redrawList)
|
boolean |
areAllItemsEnabled()
|
void |
clear()
|
protected abstract android.view.View |
doGetView(int position,
android.view.View convertView,
android.view.ViewGroup parent)
|
int |
getCount()
|
ArrayList<T> |
getData()
|
T |
getItem(int position)
|
int |
getItemCount()
|
long |
getItemId(int position)
|
int |
getItemViewType(int position)
|
android.widget.AbsListView |
getListView()
|
android.view.View |
getProgressView()
|
android.view.View |
getView(int position,
android.view.View convertView,
android.view.ViewGroup parent)
|
int |
getViewTypeCount()
|
boolean |
hasItems()
|
boolean |
isEmpty()
|
boolean |
isEnabled(int position)
|
boolean |
isLoadingData()
|
void |
remove(int position)
|
void |
setIsLoadingData(boolean isLoadingData)
|
void |
setIsLoadingData(boolean isLoadingData,
boolean redrawList)
|
boolean |
shouldRequestNextPage(int firstVisibleItem,
int visibleItemCount,
int totalItemCount)
Call this method from AbsListView.OnScrollListener.onScroll(AbsListView, int, int, int) to
determine whether the adapter should fetch the next page of data. |
Methods inherited from class android.widget.BaseAdapter |
getDropDownView, hasStableIds, notifyDataSetChanged, notifyDataSetInvalidated, registerDataSetObserver, unregisterDataSetObserver |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EndlessListAdapter
public EndlessListAdapter(android.app.ListActivity activity,
int progressItemLayoutResId)
EndlessListAdapter
public EndlessListAdapter(android.app.ExpandableListActivity activity,
int progressItemLayoutResId)
EndlessListAdapter
public EndlessListAdapter(android.app.Activity activity,
android.widget.AbsListView listView,
int progressItemLayoutResId)
getListView
public android.widget.AbsListView getListView()
getProgressView
public android.view.View getProgressView()
getCount
public int getCount()
-
Don't use this to check for the presence of actual data items; use hasItems()
instead.
isEmpty
public boolean isEmpty()
-
Don't use this to check for the presence of actual data items; use hasItems()
instead.
- Specified by:
isEmpty
in interface android.widget.Adapter
- Overrides:
isEmpty
in class android.widget.BaseAdapter
getItemCount
public int getItemCount()
- Returns:
- the actual number of data items in this adapter, ignoring the progress item.
hasItems
public boolean hasItems()
- Returns:
- true if there are actual data items, ignoring the progress item.
getItem
public T getItem(int position)
getItemId
public long getItemId(int position)
isEnabled
public boolean isEnabled(int position)
- Specified by:
isEnabled
in interface android.widget.ListAdapter
- Overrides:
isEnabled
in class android.widget.BaseAdapter
areAllItemsEnabled
public boolean areAllItemsEnabled()
- Specified by:
areAllItemsEnabled
in interface android.widget.ListAdapter
- Overrides:
areAllItemsEnabled
in class android.widget.BaseAdapter
setIsLoadingData
public void setIsLoadingData(boolean isLoadingData)
setIsLoadingData
public void setIsLoadingData(boolean isLoadingData,
boolean redrawList)
isLoadingData
public boolean isLoadingData()
getView
public final android.view.View getView(int position,
android.view.View convertView,
android.view.ViewGroup parent)
doGetView
protected abstract android.view.View doGetView(int position,
android.view.View convertView,
android.view.ViewGroup parent)
getItemViewType
public int getItemViewType(int position)
- Specified by:
getItemViewType
in interface android.widget.Adapter
- Overrides:
getItemViewType
in class android.widget.BaseAdapter
getViewTypeCount
public int getViewTypeCount()
- Specified by:
getViewTypeCount
in interface android.widget.Adapter
- Overrides:
getViewTypeCount
in class android.widget.BaseAdapter
getData
public ArrayList<T> getData()
addAll
public void addAll(List<T> items)
addAll
public void addAll(List<T> items,
boolean redrawList)
clear
public void clear()
remove
public void remove(int position)
shouldRequestNextPage
public boolean shouldRequestNextPage(int firstVisibleItem,
int visibleItemCount,
int totalItemCount)
- Call this method from
AbsListView.OnScrollListener.onScroll(AbsListView, int, int, int)
to
determine whether the adapter should fetch the next page of data.
A typical implementation in your Activity might look like this:
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
int totalItemCount) {
if (adapter.shouldRequestNextPage(firstVisibleItem, visibleItemCount, totalItemCount)) {
// fetch next page, e.g. make a Web service call
// ...
adapter.setIsLoadingData(true);
}
}
- Parameters:
firstVisibleItem
- passed down from AbsListView.OnScrollListener.onScroll(AbsListView, int, int, int)
visibleItemCount
- passed down from AbsListView.OnScrollListener.onScroll(AbsListView, int, int, int)
totalItemCount
- passed down from AbsListView.OnScrollListener.onScroll(AbsListView, int, int, int)
- Returns:
- true if the bottom of the list was reached, and hence the next page of data should be
loaded
Copyright © 2012. All Rights Reserved.