package epson.scan.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import epson.common.Constants;
import epson.common.CustomListRow;
import epson.common.CustomListRowAdapter;
import epson.common.CustomListRowImpl;
import epson.print.ActivityIACommon;
import epson.print.C2135R;
import epson.print.Util.EPLog;
import epson.scan.activity.ScanSettingsDetailAdapter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

public class ScanSettingsAdvanceDetailActivity extends ActivityIACommon {
    private static final String SCAN_SETTINGS_LAST_VALUE = "SCAN_SETTINGS_LAST_VALUE";
    private List<CustomListRow> items;
    /* access modifiers changed from: private */
    public int lastAdfRotate;
    /* access modifiers changed from: private */
    public int lastValue;
    private LinkedHashMap<String, Integer> lhmListOptionValue;
    private ListView listSelect;
    /* access modifiers changed from: private */
    public ListView listSelect2;
    private AdapterView.OnItemClickListener mListOptionClick = new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
            if (view.getTag() instanceof ScanSettingsDetailAdapter.DetailSettingHolder) {
                ScanSettingsDetailAdapter.DetailSettingHolder detailSettingHolder = (ScanSettingsDetailAdapter.DetailSettingHolder) view.getTag();
                Intent intent = ScanSettingsAdvanceDetailActivity.this.getIntent();
                int access$000 = ScanSettingsAdvanceDetailActivity.this.screenId;
                if (access$000 == C2135R.string.str_settings_2sided_title) {
                    int unused = ScanSettingsAdvanceDetailActivity.this.lastValue = detailSettingHolder.value;
                    String unused2 = ScanSettingsAdvanceDetailActivity.this.strSelText = detailSettingHolder.text.getText().toString();
                    ScanSettingsAdvanceDetailActivity.this.ssdAdapter.setSelected(ScanSettingsAdvanceDetailActivity.this.lastValue);
                    ScanSettingsAdvanceDetailActivity.this.ssdAdapter.notifyDataSetChanged();
                    if (ScanSettingsAdvanceDetailActivity.this.lastValue == 1) {
                        ScanSettingsAdvanceDetailActivity.this.listSelect2.setVisibility(0);
                    } else {
                        ScanSettingsAdvanceDetailActivity.this.listSelect2.setVisibility(8);
                    }
                } else if (access$000 == C2135R.string.str_settings_gamma_title) {
                    intent.putExtra(Constants.SCAN_REFS_SETTINGS_GAMMA, detailSettingHolder.value);
                    intent.putExtra(Constants.SCAN_REFS_SETTINGS_GAMMA_NAME, detailSettingHolder.text.getText().toString());
                    ScanSettingsAdvanceDetailActivity.this.setResult(-1, intent);
                    ScanSettingsAdvanceDetailActivity.this.finish();
                }
            }
        }
    };
    private AdapterView.OnItemClickListener mListOptionClick2 = new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
            EPLog.m313i("mListOptionClick2", "[position]" + i);
            EPLog.m313i("mListOptionClick2", "[id]" + j);
            int unused = ScanSettingsAdvanceDetailActivity.this.lastAdfRotate = i;
            switch (i) {
                case 0:
                    ScanSettingsAdvanceDetailActivity.this.mlAdapter.setList(0, CustomListRowImpl.create().addText("").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_counter_direction)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
                    ScanSettingsAdvanceDetailActivity.this.mlAdapter.setList(1, CustomListRowImpl.create().addText("").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_same_direction)));
                    break;
                case 1:
                    ScanSettingsAdvanceDetailActivity.this.mlAdapter.setList(0, CustomListRowImpl.create().addText("").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_counter_direction)));
                    ScanSettingsAdvanceDetailActivity.this.mlAdapter.setList(1, CustomListRowImpl.create().addText("").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_same_direction)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
                    break;
            }
            ScanSettingsAdvanceDetailActivity.this.mlAdapter.notifyDataSetChanged();
        }
    };
    /* access modifiers changed from: private */
    public CustomListRowAdapter mlAdapter;
    /* access modifiers changed from: private */
    public int screenId;
    private String screenTitle;
    /* access modifiers changed from: private */
    public ScanSettingsDetailAdapter ssdAdapter;
    /* access modifiers changed from: private */
    public String strSelText;
    private int supportedAdfDuplex;

    /* access modifiers changed from: protected */
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView((int) C2135R.layout.scan_settings_detail_2);
        Bundle extras = getIntent().getExtras();
        this.screenId = extras.getInt(Constants.SCAN_SETTINGS_DETAIL_TITLE);
        this.lastValue = extras.getInt(SCAN_SETTINGS_LAST_VALUE);
        this.supportedAdfDuplex = extras.getInt(Constants.SCAN_REFS_OPTIONS_SUPPORTED_ADF_DUPLEX);
        this.lastAdfRotate = extras.getInt(Constants.SCAN_REFS_SETTINGS_ROTATE);
        this.listSelect = (ListView) findViewById(C2135R.C2137id.lvScannerSettingOptions);
        this.listSelect2 = (ListView) findViewById(C2135R.C2137id.lvScannerSettingOptions2);
        getListCorespondenceOptions(this.screenId);
        setListCorespondenceOptions(this.screenId);
        setActionBar(getTitle().toString(), true);
    }

    private void getListCorespondenceOptions(int i) {
        this.items = new ArrayList();
        this.lhmListOptionValue = new LinkedHashMap<>();
        if (i == C2135R.string.str_settings_2sided_title) {
            this.screenTitle = getString(C2135R.string.str_settings_2sided_title);
            if (this.supportedAdfDuplex == 1) {
                this.lhmListOptionValue.put(getString(C2135R.string.str_yes), 1);
            }
            this.lhmListOptionValue.put(getString(C2135R.string.str_no), 0);
            switch (this.lastAdfRotate) {
                case 0:
                    this.items.add(CustomListRowImpl.create().addText(" ").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_counter_direction)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
                    this.items.add(CustomListRowImpl.create().addText("").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_same_direction)));
                    return;
                case 1:
                    this.items.add(CustomListRowImpl.create().addText(" ").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_counter_direction)));
                    this.items.add(CustomListRowImpl.create().addText("").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_same_direction)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
                    return;
                default:
                    return;
            }
        } else if (i == C2135R.string.str_settings_gamma_title) {
            this.screenTitle = getString(C2135R.string.str_settings_gamma_title);
            this.lhmListOptionValue.put(getString(C2135R.string.str_settings_gamma_10), 0);
            this.lhmListOptionValue.put(getString(C2135R.string.str_settings_gamma_18), 1);
        }
    }

    private void setListCorespondenceOptions(int i) {
        setTitle(this.screenTitle);
        if (i == C2135R.string.str_settings_2sided_title) {
            this.mlAdapter = new CustomListRowAdapter(this, C2135R.layout.com_customline_row, this.items);
            this.listSelect2.setAdapter(this.mlAdapter);
            this.listSelect2.setOnItemClickListener(this.mListOptionClick2);
            if (this.lastValue == 1) {
                this.listSelect2.setVisibility(0);
            } else {
                this.listSelect2.setVisibility(8);
            }
        }
        this.ssdAdapter = new ScanSettingsDetailAdapter(getBaseContext(), this.lhmListOptionValue, this.lastValue);
        this.listSelect.setAdapter(this.ssdAdapter);
        this.listSelect.setOnItemClickListener(this.mListOptionClick);
    }

    public void onBackPressed() {
        Intent intent = getIntent();
        int i = this.screenId;
        if (i == C2135R.string.str_settings_2sided_title) {
            if (this.lastValue == 1) {
                this.strSelText = getString(C2135R.string.str_yes);
            } else {
                this.strSelText = getString(C2135R.string.str_no);
            }
            intent.putExtra(Constants.SCAN_REFS_SETTINGS_2SIDED, this.lastValue);
            intent.putExtra(Constants.SCAN_REFS_SETTINGS_2SIDED_NAME, this.strSelText);
            intent.putExtra(Constants.SCAN_REFS_SETTINGS_ROTATE, this.lastAdfRotate);
            setResult(-1, intent);
        } else if (i == C2135R.string.str_settings_gamma_title) {
            setResult(0, intent);
        }
        finish();
        super.onBackPressed();
    }
}
