final List<Object> data = new ArrayList<Object>();
data.addAll(EMPLOYEE_LIST);
data.addAll(EMPLOYER_LIST);
Collections.shuffle(data);
mMultiTypeAdapter.addAll(data, new MultiTypeAdapter.MultiViewTyper() {
@Override
public int getViewType(Object item) {
if (item instanceof EmployerViewModel) {
return VIEW_TYPE_EMPLOYER;
}
if (item instanceof EmployeeViewModel) {
return VIEW_TYPE_EMPLOYEE;
}
return 0;
}
});
添加 MultiViewTyper接口,方便从不确定顺序的数据中获取viewType。