package epson.scan.activity;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;

import epson.print.R;

public class StringListAdapter extends BaseAdapter {
    private int mCurrentPosition;
    private LayoutInflater mLayoutInflater;
    private String[] mStringArray;

    public long getItemId(int i) {
        return (long) i;
    }

    public StringListAdapter(Context context, String[] strArr, int i) {
        mLayoutInflater = LayoutInflater.from(context);
        mStringArray = strArr;
        mCurrentPosition = i;
    }

    public int getCount() {
        return mStringArray.length;
    }

    public Object getItem(int i) {
        return 0;
    }

    public View getView(int i, View view, ViewGroup viewGroup) {
        int i2 = 0;
        if (view == null) {
            view = mLayoutInflater.inflate(R.layout.i2_scan_setting_item, viewGroup, false);
        }
        ((TextView) view.findViewById(R.id.tvSettingName)).setText(mStringArray[i]);
        ImageView imageView = (ImageView) view.findViewById(R.id.ivSettingSelected);
        if (i != mCurrentPosition) {
            i2 = 8;
        }
        imageView.setVisibility(i2);
        return view;
    }

    public static class Builder implements LocalListAdapterBuilder {
        private int mCurrentPosition;
        private String[] mStringArray;

        public Builder(String[] strArr, int i) {
            mStringArray = strArr;
            mCurrentPosition = i;
        }

        public ListAdapter build(Context context) {
            return new StringListAdapter(context, mStringArray, mCurrentPosition);
        }
    }
}
