package com.fands.hospitalmannagmentsystem.DataBaseHelper;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;

import com.fands.hospitalmannagmentsystem.R;

import java.util.List;

/**
 * Created by Fastlane on 15-11-2017.
 */

public class ListActivityAdapter extends BaseAdapter implements ListAdapter{

    private List<ListActivityModel> listmodel;
    private Context context;

    public ListActivityAdapter(List<ListActivityModel> listview, Context context) {
        this.listmodel = listview;
        this.context = context;
    }

    @Override
    public int getCount() {
        return listmodel.size();
    }

    @Override
    public Object getItem(int i) {
        return listmodel.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.list_of_items, parent,false);

        ListActivityModel Model=listmodel.get(position);

        String strpaitentname=Model.getStrPaitentname();
        String strdoctorname=Model.getStrdoctorname();
        String strTimestamp=Model.getStrtimestamp();

        TextView tvpaitentview=(TextView)view.findViewById(R.id.txt_Paitentname);
        TextView tvdoctor=(TextView)view.findViewById(R.id.txt_doctorname);
        TextView tvtimestamp=(TextView)view.findViewById(R.id.txt_Timestamp);

        tvdoctor.setText(strdoctorname);
        tvpaitentview.setText(strpaitentname);
        tvtimestamp.setText(strTimestamp);
//        Log.d("abc",strpaitentname );

        return view;
    }
}
