package ca.antonious.habittracker;

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.ArrayList;
import java.util.List;

import ca.antonious.habittracker.models.Habit;

/**
 * Created by George on 2016-09-01.
 */
public class HabitAdapter extends RecyclerView.Adapter<HabitAdapter.ViewHolder> {
    private List<Habit> habits = new ArrayList<>();

    public void setHabits(List<? extends Habit> habits) {
        this.habits.clear();
        this.habits.addAll(habits);
    }

    @Override
    public HabitAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.habit_list_item, parent, false);

        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(HabitAdapter.ViewHolder holder, int position) {
        Habit habit = habits.get(position);

        holder.setTitle(habit.getName());
    }

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

    public static class ViewHolder extends RecyclerView.ViewHolder {
        private TextView title;

        public ViewHolder(View view) {
            super(view);

            title = (TextView) view.findViewById(R.id.habit_title);

            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                }
            });
        }

        public void setTitle(String title) {
            this.title.setText(title);
        }
    }
}

@@ -477,24 +477,90 @@
 yList%3C%3E();%0A%0A
+    public HabitAdapter() %7B%0A        setHasStableIds(true);%0A    %7D%0A%0A
     public v
@@ -669,32 +669,118 @@
 habits);%0A    %7D%0A%0A
+    public Habit getHabit(int position) %7B%0A        return habits.get(position);%0A    %7D%0A%0A
     @Override%0A  
@@ -1138,25 +1138,23 @@
 habit = 
-habits.ge
+getHabi
 t(positi
@@ -1283,32 +1283,149 @@
 .size();%0A    %7D%0A%0A
+    @Override%0A    public long getItemId(int position) %7B%0A        return getHabit(position).getId().hashCode();%0A    %7D%0A%0A
     public stati

Make habit adapter use "stableIds" for them sweet animations