package app.brest.app.brest.ui;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

import app.brest.testmin3d.ResourceListActivity;
import app.brest.testmin3d.ViewerActivity;
import app.brest.utils.app.brest.game.Resource;

/**
 * Created by ptitcois on 22/08/16.
 */
public class ResourceArrayAdapter extends ArrayAdapter<Resource> implements  AdapterView.OnItemClickListener{
    protected Context mContext;

    public ResourceArrayAdapter(Context context, int resource, List<Resource> objects) {
        super(context, resource, objects);
        mContext=context;

    }

    @Override
    public View getView(int position, View convertView,
                        ViewGroup parent) {
        View view =super.getView(position, convertView, parent);

        TextView textView=(TextView) view.findViewById(android.R.id.text1);

            /*YOUR CHOICE OF COLOR*/
        textView.setTextColor(Color.rgb(0x33, 0xb5, 0xe5));

        return view;
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        Resource item = (Resource)adapterView.getItemAtPosition(i);

        Intent intent = new Intent(mContext, ViewerActivity.class);
        intent.putExtra("resource", item);
        mContext.startActivity(intent);
    }
}
