public abstract class BaseCursorPagerAdapter extends BaseFragmentPagerAdapter
Modifier and Type | Field and Description |
---|---|
protected Context |
mContext |
protected Cursor |
mCursor |
protected SparseIntArray |
mItemPosition
Mapping of row ID to cursor position
|
protected HashMap<Object,Integer> |
mObjectRowMap
Mapping of instantiated object to row ID
|
protected int |
mRowIDColumn |
POSITION_NONE, POSITION_UNCHANGED
Constructor and Description |
---|
BaseCursorPagerAdapter(Context context,
FragmentManager fm,
Cursor c)
Constructor that always enables auto-requery.
|
Modifier and Type | Method and Description |
---|---|
CharSequence |
convertToString(Cursor cursor)
Converts the cursor into a CharSequence.
|
void |
destroyItem(View container,
int position,
Object object)
Remove a page for the given position.
|
int |
getCount()
Return the number of views available.
|
Cursor |
getCursor()
Returns the cursor.
|
Object |
getDataItem(int position)
Returns the data item associated with the specified position in the data set.
|
abstract Fragment |
getItem(Context context,
Cursor cursor,
int position)
Makes a fragment for the data pointed to by the cursor
|
Fragment |
getItem(int position)
Return the Fragment associated with a specified position.
|
long |
getItemId(int position)
Returns the row id associated with the specified position in the list.
|
int |
getItemPosition(Object object)
Called when the host view is attempting to determine if an item's position
has changed.
|
Object |
instantiateItem(View container,
int position)
Create the page for the given position.
|
boolean |
isDataValid() |
protected String |
makeFragmentName(int viewId,
int index)
Creates a name for the fragment
|
Cursor |
swapCursor(Cursor newCursor)
Swap in a new Cursor, returning the old Cursor.
|
finishUpdate, isViewFromObject, restoreState, saveState, setPrimaryItem, startUpdate
destroyItem, finishUpdate, getPageTitle, getPageWidth, instantiateItem, notifyDataSetChanged, registerDataSetObserver, setPrimaryItem, startUpdate, unregisterDataSetObserver
protected Context mContext
protected Cursor mCursor
protected int mRowIDColumn
protected SparseIntArray mItemPosition
public BaseCursorPagerAdapter(Context context, FragmentManager fm, Cursor c)
c
- The cursor from which to get the data.context
- The contextpublic abstract Fragment getItem(Context context, Cursor cursor, int position)
context
- Interface to application's global informationcursor
- The cursor from which to get the data. The cursor is already
moved to the correct position.public Fragment getItem(int position)
BaseFragmentPagerAdapter
getItem
in class BaseFragmentPagerAdapter
public int getCount()
PagerAdapter
getCount
in class PagerAdapter
public Object instantiateItem(View container, int position)
PagerAdapter
PagerAdapter.finishUpdate(ViewGroup)
.instantiateItem
in class BaseFragmentPagerAdapter
container
- The containing View in which the page will be shown.position
- The page position to be instantiated.public void destroyItem(View container, int position, Object object)
PagerAdapter
PagerAdapter.finishUpdate(View)
.destroyItem
in class BaseFragmentPagerAdapter
container
- The containing View from which the page will be removed.position
- The page position to be removed.object
- The same object that was returned by
PagerAdapter.instantiateItem(View, int)
.public int getItemPosition(Object object)
PagerAdapter
PagerAdapter.POSITION_UNCHANGED
if the position of the given
item has not changed or PagerAdapter.POSITION_NONE
if the item is no longer present
in the adapter.
The default implementation assumes that items will never
change position and always returns PagerAdapter.POSITION_UNCHANGED
.
getItemPosition
in class PagerAdapter
object
- Object representing an item, previously returned by a call to
PagerAdapter.instantiateItem(View, int)
.PagerAdapter.getCount()
),
PagerAdapter.POSITION_UNCHANGED
if the object's position has not changed,
or PagerAdapter.POSITION_NONE
if the item is no longer present.public boolean isDataValid()
public Cursor getCursor()
public Object getDataItem(int position)
public long getItemId(int position)
public Cursor swapCursor(Cursor newCursor)
newCursor
- The new cursor to be used.public CharSequence convertToString(Cursor cursor)
cursor
- the cursor to convert to a CharSequenceprotected String makeFragmentName(int viewId, int index)
BaseFragmentPagerAdapter
makeFragmentName
in class BaseFragmentPagerAdapter