package io.fabianterhorst.fastlayout.sample;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.mikepenz.fastadapter.items.AbstractItem;
import com.mikepenz.materialize.holder.StringHolder;

/**
 * Created by fabianterhorst on 16.05.16.
 */
public class SampleItem extends AbstractItem<SampleItem, SampleItem.ViewHolder> {

    public StringHolder name;

    public SampleItem withName(String name) {
        this.name = new StringHolder(name);
        return this;
    }

    @Override
    public int getType() {
        return R.id.sample_item;
    }

    @Override
    public int getLayoutRes() {
        return -1;
    }

    @Override
    public View generateView(Context ctx) {
        RecyclerView.ViewHolder viewHolder = getViewHolder(LayoutCache.getInstance(ctx).getLayout(LayoutCache.Item_Sample_Layout));
        bindView((SampleItem.ViewHolder) viewHolder);
        return viewHolder.itemView;
    }

    @Override
    public void bindView(ViewHolder viewHolder) {
        super.bindView(viewHolder);
        name.applyToOrHide(viewHolder.name);
    }

    protected static class ViewHolder extends RecyclerView.ViewHolder {

        protected TextView name;

        public ViewHolder(View view) {
            super(view);
            this.name = (TextView) view.findViewById(R.id.name);
        }
    }
}

@@ -43,40 +43,8 @@
 e;%0A%0A
-import android.content.Context;%0A
 impo
@@ -106,24 +106,29 @@
 id.view.View
+Group
 ;%0Aimport and
@@ -724,257 +724,121 @@
 View
- generateView(Context ctx) %7B%0A        RecyclerView.ViewHolder viewHolder = getViewHolder(LayoutCache.getInstance(ctx).getLayout(LayoutCache.
+Holder getViewHolder(ViewGroup parent) %7B%0A        return new ViewHolder(new 
 Item
-_
 Sample
-_
 Layout
-));%0A        bindView((SampleItem.ViewHolder) viewHolder);%0A        return viewHolder.itemView
+(parent.getContext()))
 ;%0A  
@@ -1127,20 +1127,32 @@
 wHolder(
-View
+ItemSampleLayout
  view) %7B
@@ -1205,46 +1205,21 @@
 e = 
-(TextView) view.findViewById(R.id.n
+view.getN
 ame
+(
 );%0A 

improve sample item