class RecyclerItemAdapter extends RecyclerView.Adapter<ItemViewHolder> implements ItemHierarchy.Observer {

  @Override
  public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    final View view = inflater.inflate(viewType, parent, false);
    final ItemViewHolder viewHolder = new ItemViewHolder(view);

    final Object viewTag = view.getTag();
    if (!TAG_NO_BACKGROUND.equals(viewTag)) {
      final TypedArray typedArray =
          parent.getContext().obtainStyledAttributes(R.styleable.SuwRecyclerItemAdapter);
      Drawable selectableItemBackground =
          typedArray.getDrawable(
              R.styleable.SuwRecyclerItemAdapter_android_selectableItemBackground);
      if (selectableItemBackground == null) {
        selectableItemBackground =
            typedArray.getDrawable(R.styleable.SuwRecyclerItemAdapter_selectableItemBackground);
      }

      Drawable background = view.getBackground();
      if (background == null) {
        background =
            typedArray.getDrawable(R.styleable.SuwRecyclerItemAdapter_android_colorBackground);
      }

      if (selectableItemBackground == null || background == null) {
        Log.e(
            TAG,
            "Cannot resolve required attributes."
                + " selectableItemBackground="
                + selectableItemBackground
                + " background="
                + background);
      } else {
        final Drawable[] layers = {background, selectableItemBackground};
        view.setBackgroundDrawable(new PatchedLayerDrawable(layers));
      }

      typedArray.recycle();
    }

    view.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            final IItem item = viewHolder.getItem();
            if (listener != null && item != null && item.isEnabled()) {
              listener.onItemSelected(item);
            }
          }
        });

    return viewHolder;
  }

  public  RecyclerItemAdapter(ItemHierarchy hierarchy);

}