package com.bonait.bnframework.modules.home.adapter;

import android.content.Context;
import android.graphics.text.TextRunShaper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.model.mode.ResMenuLeft;
import com.bonait.bnframework.modules.home.fragment.JiaoYanFragment;

import java.util.ArrayList;

public class jiaoyan_adapter extends BaseAdapter {

    private Context context;
    private ArrayList<ResMenuLeft> Data;
    public static int mPosition;

    public jiaoyan_adapter(Context context, ArrayList<ResMenuLeft> strings){
        this.context =context;
        this.Data = strings;
    }

    @Override
    public int getCount() {
        return Data.size();
    }

    @Override
    public Object getItem(int i) {
        return Data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return mPosition;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        convertView = LayoutInflater.from(context).inflate(R.layout.meun_jiaoyan_left, null);
        mPosition = position;
        ResMenuLeft left=Data.get(position);


        RelativeLayout menu_main = (RelativeLayout) convertView.findViewById(R.id.menu_main);
        TextView name = (TextView) convertView.findViewById(R.id.name);
        ImageView image = (ImageView) convertView.findViewById(R.id.image);

        name.setText(left.name);
        if (position == JiaoYanFragment.mPosition) {
            //convertView.setBackgroundColor(Color.parseColor("#FF074B92"));
            name.setTextColor(context.getResources().getColor(R.color.app_color_blue ) );
            convertView.setBackgroundResource(R.color.main_background);
            image.setImageResource(left.SelectUrl);
            left.Isselect= true;
        } else {
            name.setTextColor(context.getResources().getColor(R.color.tab_text_normal) );
            convertView.setBackgroundResource(R.color.activity_background1);
            image.setImageResource(left.Url);
            left.Isselect= false;
        }
        return convertView;
    }

    /**
     * 选中
     * @param mPosition
     */
    public void SelectIndex(int mPosition)
    {

    }
}
