public abstract class ShardPagerAdapter
extends PagerAdapter
PagerAdapter that represents each page as a Shard.
Subclasses only need to implement getItem(int)
and #getCount() to have a working adapter.
ViewPager#getOffscreenPageLimit() number of shards will be kept in memory. Otherwise
their state will be saved and the shard destroyed. The current shard will be in the resumed
state and all other shards will be in the started state. You must override
getItemPosition(Shard) if you want to be able to dynamically change the contents on a
#notifyDataSetChanged().
| Constructor and Description |
|---|
ShardPagerAdapter(Context context) |
ShardPagerAdapter(ShardOwner owner) |
| Modifier and Type | Method and Description |
|---|---|
void |
destroyItem(ViewGroup container,
int position,
java.lang.Object object) |
abstract Shard |
getItem(int position) |
int |
getItemPosition(java.lang.Object object) |
int |
getItemPosition(Shard shard)
Called when the host view is attempting to determine if an item's position
has changed.
|
java.lang.Object |
instantiateItem(ViewGroup container,
int position) |
boolean |
isViewFromObject(View view,
java.lang.Object object) |
void |
restoreState(Parcelable state,
java.lang.ClassLoader loader) |
Parcelable |
saveState() |
void |
setPrimaryItem(ViewGroup container,
int position,
java.lang.Object object) |
public ShardPagerAdapter(Context context)
public ShardPagerAdapter(ShardOwner owner)
public java.lang.Object instantiateItem(ViewGroup container,
int position)
public void destroyItem(ViewGroup container,
int position,
java.lang.Object object)
public final int getItemPosition(java.lang.Object object)
public int getItemPosition(Shard shard)
#POSITION_UNCHANGED if the position of the given
item has not changed or #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 #POSITION_UNCHANGED.
shard - Shard representing an item, previously returned by a call to
#instantiateItem(View, int).#getCount()),
#POSITION_UNCHANGED if the object's position has not changed,
or #POSITION_NONE if the item is no longer present.public void setPrimaryItem(ViewGroup container,
int position,
java.lang.Object object)
public abstract Shard getItem(int position)
public final boolean isViewFromObject(View view,
java.lang.Object object)
public void restoreState(Parcelable state,
java.lang.ClassLoader loader)
public Parcelable saveState()