@Test public void onCreateViewHolder() throws Exception { UniversalAdapter adapter = new UniversalAdapter(Arrays.asList(mBuilder1, mBuilder2)); ViewGroup parent = Mockito.mock(ViewGroup.class); DefaultViewHolder viewHolder = adapter.onCreateViewHolder(parent, mBuilder1.getId()); Assert.assertThat(viewHolder.getItemViewType(), Is.is(mBuilder1.getId())); }
@Override @NonNull public DefaultViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return mBuilders.get(viewType).build(parent); }
UniversalAdapter extends RecyclerView.Adapter<DefaultViewHolder> { @Override @NonNull public DefaultViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return mBuilders.get(viewType).build(parent); } }
UniversalAdapter extends RecyclerView.Adapter<DefaultViewHolder> { @Override @NonNull public DefaultViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return mBuilders.get(viewType).build(parent); } UniversalAdapter(Builder... builders);  UniversalAdapter(List<Builder> builders); }
UniversalAdapter extends RecyclerView.Adapter<DefaultViewHolder> { @Override @NonNull public DefaultViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return mBuilders.get(viewType).build(parent); } UniversalAdapter(Builder... builders);  UniversalAdapter(List<Builder> builders); @Override @NonNull DefaultViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType); @SuppressWarnings("unchecked") @Override void onBindViewHolder(@NonNull DefaultViewHolder holder, int position); @Override int getItemViewType(int position); @Override int getItemCount(); int getItemCount(Class itemClass); void add(int pos, ViewModelWrapper wrapper); void replace(int index, Object item, int holderId); void replace(int index, Object item); boolean add(ViewModelWrapper wrapper); void add(Object item, int builderId); boolean add(Object item); boolean add(int index, Object item); void add(int index, Object item, int builderId); Object getItem(int position); void addAll(List items); void addAll(List items, int builderId); void replaceAll(List items); void replaceAll(List items, int builderId); void addAllWrappers(List<ViewModelWrapper> items); void replaceAllWrappers(List<ViewModelWrapper> elements); void removeItems(int startIndex, int endIndex); boolean clear(); int indexOf(Object searchItem); }
UniversalAdapter extends RecyclerView.Adapter<DefaultViewHolder> { @Override @NonNull public DefaultViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return mBuilders.get(viewType).build(parent); } UniversalAdapter(Builder... builders);  UniversalAdapter(List<Builder> builders); @Override @NonNull DefaultViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType); @SuppressWarnings("unchecked") @Override void onBindViewHolder(@NonNull DefaultViewHolder holder, int position); @Override int getItemViewType(int position); @Override int getItemCount(); int getItemCount(Class itemClass); void add(int pos, ViewModelWrapper wrapper); void replace(int index, Object item, int holderId); void replace(int index, Object item); boolean add(ViewModelWrapper wrapper); void add(Object item, int builderId); boolean add(Object item); boolean add(int index, Object item); void add(int index, Object item, int builderId); Object getItem(int position); void addAll(List items); void addAll(List items, int builderId); void replaceAll(List items); void replaceAll(List items, int builderId); void addAllWrappers(List<ViewModelWrapper> items); void replaceAllWrappers(List<ViewModelWrapper> elements); void removeItems(int startIndex, int endIndex); boolean clear(); int indexOf(Object searchItem);  }