/ RecyclerView

A single adapter with multiple view types for the whole project

A single adapter with multiple view types for the whole project

Renderer RecyclerView Adapter

A single adapter with multiple view types for the whole project.

Examples

All View Renderer View Binder Load More
Example Example Example Example
Composite ViewState Diff Util Payload
Example Example Example Example

Wiki

https://github.com/vivchar/RendererRecyclerViewAdapter/wiki

Gradle

dependencies {
    compile 'com.github.vivchar:RendererRecyclerViewAdapter:2.8.0'
}

BETA

Include this feature https://github.com/vivchar/RendererRecyclerViewAdapter/issues/32

maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }

dependencies {
    compile 'com.github.vivchar:RendererRecyclerViewAdapter:2.9.0-SNAPSHOT'
}

Usage

  • Step 1: Add the ViewModel interface to your UI model
public class SomeModel implements ViewModel {
	...
}
  • Step 2: Create your item_layout
<LinearLayout ... >
	<TextView android:id = "@+id/title" ... />
	<ImageView android:id = "@+id/image" ... />
	<Button android:id = "@+id/button" ... />
	<CustomView android:id = "@+id/custom" ... />
</LinearLayout>
  • Step 3: Initialize Adapter and register the ViewBinder
mRecyclerViewAdapter = new RendererRecyclerViewAdapter();

mRecyclerViewAdapter.registerRenderer(new ViewBinder<>(
	R.layout.item_layout,
	SomeModel.class,
	(model, finder, payloads) -> finder
		.find(R.id.custom, (ViewProvider<CustomView>) customView -> { ... })
		.setBackground(R.id.image, model.getBackground())
		.setText(R.id.text, model.getText())
		.setOnClickListener(R.id.button, v -> { ... })
));
mRecyclerViewAdapter.registerRenderer(...); /* you can use several types of cells */

/* Regular code:
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setAdapter(mRecyclerViewAdapter);

mRecyclerViewAdapter.setItems(getItems());
mRecyclerViewAdapter.notifyDataSetChanged();
*/

GitHub