public class AppboyListAdapter extends android.widget.ArrayAdapter<Card>
This allows the stream to reuse cards when they go out of view.
IMPORTANT - When you add a new card, be sure to add the new view type and update the view count here
A card generates an impression once per viewing per open ListView. If a card is viewed more than once in a particular ListView, it generates only one impression. If closed an reopened, a card will again generate an impression. This also takes into account the case of a card being off-screen in the ListView. The card only generates an impression when it actually scrolls onto the screen.
IMPORTANT - You must call resetCardImpressionTracker() whenever the ListView is displayed. This will ensure that cards that come into view will be tracked according to the description above.
Adding and removing cards to and from the adapter should be done using the following synchronized
methods: add(Card)
,
ArrayAdapter.clear()
clear(),
replaceFeed(java.util.List)
Constructor and Description |
---|
AppboyListAdapter(android.content.Context context,
int layoutResourceId,
java.util.List<Card> cards) |
Modifier and Type | Method and Description |
---|---|
void |
add(Card card) |
void |
batchSetCardsToRead(int startIndex,
int endIndex)
Helper method to batch set cards to visually read after either an up or down scroll of the feed.
|
int |
getItemViewType(int position) |
android.view.View |
getView(int position,
android.view.View convertView,
android.view.ViewGroup parent)
Always try to use a convert view if possible, otherwise create one from scratch.
|
int |
getViewTypeCount()
Be sure to keep view count in sync with the number of card types in the stream.
|
void |
replaceFeed(java.util.List<Card> cards) |
void |
resetCardImpressionTracker()
Resets the list of viewed cards.
|
addAll, addAll, clear, createFromResource, getAutofillOptions, getContext, getCount, getDropDownView, getDropDownViewTheme, getFilter, getItem, getItemId, getPosition, insert, notifyDataSetChanged, remove, setDropDownViewResource, setDropDownViewTheme, setNotifyOnChange, sort
areAllItemsEnabled, hasStableIds, isEmpty, isEnabled, notifyDataSetInvalidated, registerDataSetObserver, setAutofillOptions, unregisterDataSetObserver
public AppboyListAdapter(android.content.Context context, int layoutResourceId, java.util.List<Card> cards)
public int getViewTypeCount()
getViewTypeCount
in interface android.widget.Adapter
getViewTypeCount
in class android.widget.BaseAdapter
public int getItemViewType(int position)
getItemViewType
in interface android.widget.Adapter
getItemViewType
in class android.widget.BaseAdapter
public android.view.View getView(int position, android.view.View convertView, android.view.ViewGroup parent)
getView
in interface android.widget.Adapter
getView
in class android.widget.ArrayAdapter<Card>
public void replaceFeed(java.util.List<Card> cards)
public void resetCardImpressionTracker()
public void batchSetCardsToRead(int startIndex, int endIndex)
startIndex
- Where to start setting cards to viewed. The card at this index will
be set to viewed. Must be less than endIndexendIndex
- Where to end setting cards to viewed. The card at this index will be set to viewed.