-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
I noticed this code in the GenericAdapter
@Override
public int getItemViewType(int position) {
Class<?> lItemClass = mObjectList.get(position).getClass();
for (int i = 0; i < mModels.size(); i++) {
if (mModels.get(i).getItemType().equals(lItemClass)) {
return i;
}
}
return -1;
}
Why is it necessary to iterate over all items to get item type? And why do you return an item position as item view type? Since items of different types can be non sequential positions like [type1, type2, type1, type2], it would be easier to just get an item and return item.getType() method result.