package id.kido1611.drawerwithrecyclerview.model;

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

import java.util.Collections;
import java.util.List;

import id.kido1611.drawerwithrecyclerview.R;

/**
 * Created by Kido1611 on 22-Apr-16.
 */
public class NavigationDrawerAdapter extends RecyclerView.Adapter<NavigationDrawerAdapter.MyViewHolder>{

    List<NavDrawerItem> data = Collections.emptyList();
    private LayoutInflater inflater;
    private Context context;

    public NavigationDrawerAdapter(Context context, List<NavDrawerItem> data) {
        this.context = context;
        inflater = LayoutInflater.from(context);
        this.data = data;
    }

    public void delete(int position) {
        data.remove(position);
        notifyItemRemoved(position);
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.nav_drawer_row, parent, false);
        MyViewHolder holder = new MyViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        NavDrawerItem current = data.get(position);
        holder.title.setText(current.getTitle());
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        TextView title;

        public MyViewHolder(View itemView) {
            super(itemView);
            title = (TextView) itemView.findViewById(R.id.title);
        }
    }
}

@@ -76,16 +76,47 @@
 ontext;%0A
+import android.graphics.Color;%0A
 import a
@@ -1207,32 +1207,65 @@
  holder;%0A    %7D%0A%0A
+    int selection_position = 0;%0A%0A
     @Override%0A  
@@ -1315,16 +1315,22 @@
  holder,
+ final
  int pos
@@ -1439,16 +1439,599 @@
 itle());
+%0A%0A        if(selection_position==position)%7B%0A            holder.itemView.setBackgroundResource(R.color.colorPrimary);%0A            holder.title.setTextColor(Color.WHITE);%0A        %7Delse%7B%0A            holder.itemView.setBackgroundColor(Color.TRANSPARENT);%0A        %7D%0A%0A        holder.itemView.setOnClickListener(new View.OnClickListener() %7B%0A            @Override%0A            public void onClick(View view) %7B%0A                notifyItemChanged(selection_position);%0A                selection_position = position;%0A                notifyItemChanged(selection_position);%0A            %7D%0A        %7D);
 %0A    %7D%0A%0A

Add indicator background on current selected fragment