Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple RecyclerAdapter. Best used with MVP module of Blade library (
package eu.f3rog.ui.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
* Class {@link RecyclerAdapter}
* @author FrantisekGazo
* @version 2016-02-27
public final class RecyclerAdapter<T>
extends RecyclerView.Adapter<MyRecyclerAdapter.ViewHolder> {
public static final class ViewHolder
extends RecyclerView.ViewHolder {
public ViewHolder(View itemView) {
private LayoutInflater mLayoutInflater;
private List<T> mItems;
private final int mLayout;
public MyRecyclerAdapter(@NonNull Context c, @NonNull List<T> items, @LayoutRes int layout) {
mLayoutInflater = LayoutInflater.from(c);
mItems = items;
mLayout = layout;
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(mLayoutInflater.inflate(mLayout, parent, false));
public void onBindViewHolder(ViewHolder holder, int position) {
public int getItemCount() {
return (mItems != null) ? mItems.size() : 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.