// Path: app/src/main/java/com/sanchez/fmf/event/FavoriteClickEvent.java
// public class FavoriteClickEvent {
//     private final String id;
//     private final String name;
// 
//     public FavoriteClickEvent(String id, String name) {
//         this.id = id;
//         this.name = name;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// }
// 
// Path: app/src/main/java/com/sanchez/fmf/event/FavoriteRemoveEvent.java
// public class FavoriteRemoveEvent {
//     private final String id;
// 
//     public FavoriteRemoveEvent(String id) {
//         this.id = id;
//     }
// 
//     public String getId() {
//         return id;
//     }
// }


import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.sanchez.fmf.R;
import com.sanchez.fmf.event.FavoriteClickEvent;
import com.sanchez.fmf.event.FavoriteRemoveEvent;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import de.greenrobot.event.EventBus;
package com.sanchez.fmf.adapter;





/**
 * Created by dakota on 9/13/15.
 */
public class FavoriteListAdapter extends RecyclerView.Adapter<FavoriteListAdapter.ViewHolder> {

    private LinkedHashMap<String, String> mDataset;
    private List<String> mKeys;

    public FavoriteListAdapter(LinkedHashMap<String, String> dataset) {
        mDataset = dataset;
        mKeys = new ArrayList<>(dataset.keySet());
    }

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

        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        String id = mKeys.get(mKeys.size() - position - 1); // Sort list by most recently added
        String name = mDataset.get(id);

        holder.mMarketName.setText(name);

        holder.mMarketName.setOnClickListener((v) -> {
            EventBus.getDefault().post(new FavoriteClickEvent(id, name));
        });

        holder.mMarketRemove.setOnClickListener((v) -> {
// Path: app/src/main/java/com/sanchez/fmf/event/FavoriteClickEvent.java
// public class FavoriteClickEvent {
//     private final String id;
//     private final String name;
// 
//     public FavoriteClickEvent(String id, String name) {
//         this.id = id;
//         this.name = name;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// }
// 
// Path: app/src/main/java/com/sanchez/fmf/event/FavoriteRemoveEvent.java
// public class FavoriteRemoveEvent {
//     private final String id;
// 
//     public FavoriteRemoveEvent(String id) {
//         this.id = id;
//     }
// 
//     public String getId() {
//         return id;
//     }
// }


// Path: app/src/main/java/com/sanchez/fmf/adapter/FavoriteListAdapter.java
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.sanchez.fmf.R;
import com.sanchez.fmf.event.FavoriteClickEvent;
import com.sanchez.fmf.event.FavoriteRemoveEvent;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import de.greenrobot.event.EventBus;

package com.sanchez.fmf.adapter;





/**
 * Created by dakota on 9/13/15.
 */
public class FavoriteListAdapter extends RecyclerView.Adapter<FavoriteListAdapter.ViewHolder> {

    private LinkedHashMap<String, String> mDataset;
    private List<String> mKeys;

    public FavoriteListAdapter(LinkedHashMap<String, String> dataset) {
        mDataset = dataset;
        mKeys = new ArrayList<>(dataset.keySet());
    }

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

        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        String id = mKeys.get(mKeys.size() - position - 1); // Sort list by most recently added
        String name = mDataset.get(id);

        holder.mMarketName.setText(name);

        holder.mMarketName.setOnClickListener((v) -> {
            EventBus.getDefault().post(new FavoriteClickEvent(id, name));
        });

        holder.mMarketRemove.setOnClickListener((v) -> {
           EventBus.getDefault().post(new FavoriteRemoveEvent(id));