package com.ae.apps.tripmeter.views.adapters;

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.ae.apps.tripmeter.R;
import com.ae.apps.tripmeter.models.TripMemberShare;

import java.util.List;

/**
 */
public class TripMemberShareRecyclerViewAdapter extends
        RecyclerView.Adapter<TripMemberShareRecyclerViewAdapter.ViewHolder> {

    private final List<TripMemberShare> mValues;

    public TripMemberShareRecyclerViewAdapter(List<TripMemberShare> items) {
        mValues = items;
    }

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

    @Override
    public void onBindViewHolder(final ViewHolder holder, int position) {
        holder.mItem = mValues.get(position);
        holder.mIdView.setText(mValues.get(position).getContactVo().getName());
        //  (new ImageView()).setImageDrawable();
        // TODO Color code for -ve or +ve amount of share
        holder.mContentView.setText(String.valueOf(mValues.get(position).getShare()));
    }

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

    public class ViewHolder extends RecyclerView.ViewHolder {
        public final View mView;
        public final TextView mIdView;
        public final TextView mContentView;
        public TripMemberShare mItem;

        public ViewHolder(View view) {
            super(view);
            mView = view;
            mIdView = (TextView) view.findViewById(R.id.txtContactName);
            mContentView = (TextView) view.findViewById(R.id.txtExpenseAmount);
        }

        @Override
        public String toString() {
            return super.toString() + " '" + mContentView.getText() + "'";
        }
    }
}

@@ -1154,47 +1154,85 @@
     
-//  (new ImageView()).setImageDrawable(
+holder.mContactImage.setImageDrawable(mValues.get(position).getContactPhoto()
 );%0A 
@@ -1640,24 +1640,70 @@
 ontentView;%0A
+        public final ImageView mContactImage;%0A
         publ
@@ -1888,24 +1888,24 @@
 ntactName);%0A
-
             
@@ -1972,16 +1972,94 @@
 mount);%0A
+            mContactImage = (ImageView) view.findViewById(R.id.contactImage);%0A
         

set profile image for expense share list