package com.kuloud.android.unity.ui.adapter;

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.ImageView;
import android.widget.TextView;

import com.kuloud.android.unity.R;
import com.kuloud.android.unity.model.Gift;

/**
 * Created by kuloud on 5/24/15.
 */
public class GirlGiftAdapter extends RecyclerView.Adapter<GirlGiftAdapter.GiftViewHolder> {
    Context mContext;
    Gift[] mGifts = new Gift[]{
            new Gift(R.drawable.ic_gift_doll, 2),
            new Gift(R.drawable.ic_gift_birthday, 3),
            new Gift(R.drawable.ic_gift_cake, 4),
            new Gift(R.drawable.ic_gift_cho, 2),
            new Gift(R.drawable.ic_gift_flower, 1),
            new Gift(R.drawable.ic_gift_food, 1),
            new Gift(R.drawable.ic_gift_fruit, 2),
            new Gift(R.drawable.ic_gift_icecream, 4),
            new Gift(R.drawable.ic_gift_kiss, 2),
            new Gift(R.drawable.ic_gift_wine, 2),
    };

    public GirlGiftAdapter(Context context) {
        mContext = context;
    }

    @Override
    public GiftViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        View v = LayoutInflater.from(mContext).inflate(R.layout.item_girl_gift, viewGroup, false);
        return new GiftViewHolder(v);
    }

    @Override
    public int getItemCount() {
        return mGifts.length;
    }

    @Override
    public void onBindViewHolder(GiftViewHolder giftViewHolder, int i) {
        giftViewHolder.gift.setImageResource(mGifts[i].drawableId);
        giftViewHolder.num.setText("x" + mGifts[i].num);
    }

    public static class GiftViewHolder extends RecyclerView.ViewHolder {
        ImageView gift;
        TextView num;

        public GiftViewHolder(View itemView) {
            super(itemView);
            gift = (ImageView) itemView.findViewById(R.id.iv_gift);
            num = (TextView) itemView.findViewById(R.id.tv_num);
        }
    }
}
