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.TextView;
import epson.print.C2135R;
import java.util.Iterator;
import java.util.LinkedHashMap;

public class ScanSettingsDetailAdapter extends BaseAdapter {
    private LinkedHashMap<String, Integer> lhmListSettingsSupport;
    private LayoutInflater mInflater;
    private int selectedValue;

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

    public ScanSettingsDetailAdapter(Context context, LinkedHashMap<String, Integer> linkedHashMap, int i) {
        this.mInflater = LayoutInflater.from(context);
        this.lhmListSettingsSupport = linkedHashMap;
        this.selectedValue = i;
    }

    public int getCount() {
        return this.lhmListSettingsSupport.size();
    }

    public Object getItem(int i) {
        return this.lhmListSettingsSupport.get(Integer.valueOf(i));
    }

    public void setSelected(int i) {
        this.selectedValue = i;
    }

    public View getView(int i, View view, ViewGroup viewGroup) {
        DetailSettingHolder detailSettingHolder;
        if (view == null) {
            view = this.mInflater.inflate(C2135R.layout.scan_settings_item, (ViewGroup) null);
            detailSettingHolder = new DetailSettingHolder();
            detailSettingHolder.text = (TextView) view.findViewById(C2135R.C2137id.tvSettingName);
            detailSettingHolder.img = (ImageView) view.findViewById(C2135R.C2137id.ivSettingSelected);
            detailSettingHolder.img.setBackgroundResource(C2135R.C2136drawable.selected);
            view.setTag(detailSettingHolder);
        } else {
            detailSettingHolder = (DetailSettingHolder) view.getTag();
        }
        Iterator<String> it = this.lhmListSettingsSupport.keySet().iterator();
        int i2 = 0;
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            String next = it.next();
            if (i2 == i) {
                int intValue = this.lhmListSettingsSupport.get(next).intValue();
                detailSettingHolder.text.setText(next);
                if (intValue == this.selectedValue) {
                    detailSettingHolder.img.setVisibility(0);
                } else {
                    detailSettingHolder.img.setVisibility(4);
                }
                detailSettingHolder.value = intValue;
            } else {
                i2++;
            }
        }
        return view;
    }

    static class DetailSettingHolder {
        ImageView img;
        TextView text;
        int value;

        DetailSettingHolder() {
        }
    }
}
