package epson.print.screen;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import com.epson.mobilephone.common.escpr.MediaInfo;
import epson.common.Constants;
import epson.print.ActivityIACommon;
import epson.print.R;
import epson.print.Util.EPLog;
import epson.print.screen.PrintSetting;
import epson.print.widgets.AbstractListBuilder;
import epson.print.widgets.CommonDataKinds;
import epson.print.widgets.LayoutEx;
import epson.print.widgets.PrinterInfoDetailBuilder;

public class PrinterInfoDetail extends ActivityIACommon {
    private final int GET_BORDER = 3;
    private final int GET_COLOR = 6;
    private final int GET_DUPLEX = 7;
    private final int GET_FEED_DIRECTION = 8;
    private final int GET_PAPER_SIZE = 1;
    private final int GET_PAPER_SOURCE = 5;
    private final int GET_PAPER_TYPE = 2;
    private final int GET_PRINTDATE = 18;
    private final int GET_QUALITY = 4;
    /* access modifiers changed from: private */
    public int[] color_info = null;
    /* access modifiers changed from: private */
    public int[] duplex_info = null;
    private int[] feed_direction_info = null;

    /* renamed from: id */
    int f405id;
    /* access modifiers changed from: private */
    public int[] info = null;
    boolean isDocumentSetting;
    /* access modifiers changed from: private */
    public int[] layout_info = null;
    AbstractListBuilder mBuilder;
    Handler mHandler = new Handler(new Handler.Callback() {
        public boolean handleMessage(Message message) {
            EPLog.i("handleMessage", "msg.what = " + message.what);
            PrinterInfoDetail printerInfoDetail = PrinterInfoDetail.this;
            PrintSetting printSetting = new PrintSetting(printerInfoDetail, printerInfoDetail.isDocumentSetting ? PrintSetting.Kind.document : PrintSetting.Kind.photo);
            printSetting.loadSettings();
            int i = message.what;
            if (i != 18) {
                switch (i) {
                    case 1:
                        if (PrinterInfoDetail.this.paper_size_info == null) {
                            int[] unused = PrinterInfoDetail.this.info = new int[1];
                            PrinterInfoDetail.this.info[0] = printSetting.paperSizeValue;
                            break;
                        } else {
                            PrinterInfoDetail printerInfoDetail2 = PrinterInfoDetail.this;
                            int[] unused2 = printerInfoDetail2.info = new int[printerInfoDetail2.paper_size_info.length];
                            PrinterInfoDetail printerInfoDetail3 = PrinterInfoDetail.this;
                            int[] unused3 = printerInfoDetail3.info = printerInfoDetail3.paper_size_info;
                            break;
                        }
                    case 2:
                        if (PrinterInfoDetail.this.paper_type_info == null) {
                            int[] unused4 = PrinterInfoDetail.this.info = new int[1];
                            PrinterInfoDetail.this.info[0] = printSetting.paperTypeValue;
                            break;
                        } else {
                            PrinterInfoDetail printerInfoDetail4 = PrinterInfoDetail.this;
                            int[] unused5 = printerInfoDetail4.info = new int[printerInfoDetail4.paper_type_info.length];
                            PrinterInfoDetail printerInfoDetail5 = PrinterInfoDetail.this;
                            int[] unused6 = printerInfoDetail5.info = printerInfoDetail5.paper_type_info;
                            break;
                        }
                    case 3:
                        if (PrinterInfoDetail.this.layout_info == null) {
                            int[] unused7 = PrinterInfoDetail.this.info = new int[1];
                            PrinterInfoDetail.this.info[0] = printSetting.layoutValue;
                            break;
                        } else {
                            PrinterInfoDetail printerInfoDetail6 = PrinterInfoDetail.this;
                            int[] unused8 = printerInfoDetail6.info = new int[printerInfoDetail6.layout_info.length];
                            PrinterInfoDetail printerInfoDetail7 = PrinterInfoDetail.this;
                            int[] unused9 = printerInfoDetail7.info = printerInfoDetail7.layout_info;
                            int i2 = 0;
                            while (true) {
                                if (i2 >= PrinterInfoDetail.this.info.length) {
                                    break;
                                } else if (PrinterInfoDetail.this.info[i2] == 8) {
                                    if (PrinterInfoDetail.this.info.length != 1) {
                                        int[] iArr = new int[(PrinterInfoDetail.this.info.length - 1)];
                                        System.arraycopy(PrinterInfoDetail.this.info, 0, iArr, 0, i2);
                                        System.arraycopy(PrinterInfoDetail.this.info, i2 + 1, iArr, i2, (PrinterInfoDetail.this.info.length - 1) - i2);
                                        int[] unused10 = PrinterInfoDetail.this.info = null;
                                        int[] unused11 = PrinterInfoDetail.this.info = iArr;
                                        break;
                                    } else {
                                        int[] unused12 = PrinterInfoDetail.this.info = null;
                                        break;
                                    }
                                } else {
                                    i2++;
                                }
                            }
                        }
                    case 4:
                        EPLog.e("CMV", "Get Quality");
                        if (PrinterInfoDetail.this.quality_info == null) {
                            int[] unused13 = PrinterInfoDetail.this.info = new int[1];
                            PrinterInfoDetail.this.info[0] = printSetting.qualityValue;
                            break;
                        } else {
                            PrinterInfoDetail printerInfoDetail8 = PrinterInfoDetail.this;
                            int[] unused14 = printerInfoDetail8.info = new int[printerInfoDetail8.quality_info.length];
                            PrinterInfoDetail printerInfoDetail9 = PrinterInfoDetail.this;
                            int[] unused15 = printerInfoDetail9.info = printerInfoDetail9.quality_info;
                            break;
                        }
                    case 5:
                        if (PrinterInfoDetail.this.paper_source_info == null) {
                            int[] unused16 = PrinterInfoDetail.this.info = new int[1];
                            PrinterInfoDetail.this.info[0] = printSetting.paperSourceValue;
                            break;
                        } else {
                            PrinterInfoDetail printerInfoDetail10 = PrinterInfoDetail.this;
                            int[] unused17 = printerInfoDetail10.info = new int[printerInfoDetail10.paper_source_info.length];
                            PrinterInfoDetail printerInfoDetail11 = PrinterInfoDetail.this;
                            int[] unused18 = printerInfoDetail11.info = printerInfoDetail11.paper_source_info;
                            break;
                        }
                    case 6:
                        if (PrinterInfoDetail.this.color_info == null) {
                            int[] unused19 = PrinterInfoDetail.this.info = new int[1];
                            PrinterInfoDetail.this.info[0] = printSetting.colorValue;
                            break;
                        } else {
                            PrinterInfoDetail printerInfoDetail12 = PrinterInfoDetail.this;
                            int[] unused20 = printerInfoDetail12.info = new int[printerInfoDetail12.color_info.length];
                            PrinterInfoDetail printerInfoDetail13 = PrinterInfoDetail.this;
                            int[] unused21 = printerInfoDetail13.info = printerInfoDetail13.color_info;
                            break;
                        }
                    case 7:
                        if (PrinterInfoDetail.this.duplex_info == null) {
                            int[] unused22 = PrinterInfoDetail.this.info = new int[1];
                            PrinterInfoDetail.this.info[0] = printSetting.duplexValue;
                            break;
                        } else {
                            PrinterInfoDetail printerInfoDetail14 = PrinterInfoDetail.this;
                            int[] unused23 = printerInfoDetail14.info = new int[printerInfoDetail14.duplex_info.length];
                            PrinterInfoDetail printerInfoDetail15 = PrinterInfoDetail.this;
                            int[] unused24 = printerInfoDetail15.info = printerInfoDetail15.duplex_info;
                            break;
                        }
                    case 8:
                        int[] unused25 = PrinterInfoDetail.this.info = new int[2];
                        PrinterInfoDetail.this.info[0] = 0;
                        PrinterInfoDetail.this.info[1] = 1;
                        break;
                }
            } else {
                int[] unused26 = PrinterInfoDetail.this.info = new int[4];
                PrinterInfoDetail.this.info[0] = 0;
                PrinterInfoDetail.this.info[1] = 1;
                PrinterInfoDetail.this.info[2] = 2;
                PrinterInfoDetail.this.info[3] = 3;
            }
            if (PrinterInfoDetail.this.info != null) {
                ((PrinterInfoDetailBuilder) PrinterInfoDetail.this.mBuilder).addPrinterInfo(PrinterInfoDetail.this.info, PrinterInfoDetail.this.mLookupTable);
            }
            return true;
        }
    });
    ViewGroup mLayout;
    MediaInfo.AbstractInfo mLookupTable;
    /* access modifiers changed from: private */
    public int[] paper_size_info = null;
    /* access modifiers changed from: private */
    public int[] paper_source_info = null;
    /* access modifiers changed from: private */
    public int[] paper_type_info = null;
    private int[] printdate_info = null;
    /* access modifiers changed from: private */
    public int[] quality_info = null;
    private int sizeIndex = 0;
    private int typeIndex = 0;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.f405id = getIntent().getExtras().getInt("ID");
        switch (this.f405id) {
            case R.id.color /*2131230930*/:
                this.color_info = getIntent().getIntArrayExtra(Constants.COLOR_INFO);
                break;
            case R.id.duplex /*2131231005*/:
                this.duplex_info = getIntent().getIntArrayExtra(Constants.DUPLEX_INFO);
                break;
            case R.id.feed_direction /*2131231037*/:
                this.feed_direction_info = getIntent().getIntArrayExtra(Constants.FEED_DIRECTION_INFO);
                break;
            case R.id.layout /*2131231158*/:
                this.layout_info = getIntent().getIntArrayExtra(Constants.LAYOUT_INFO);
                break;
            case R.id.paper_size /*2131231306*/:
                this.paper_size_info = getIntent().getIntArrayExtra(Constants.PAPER_SIZE_INFO);
                break;
            case R.id.paper_source /*2131231311*/:
                this.paper_source_info = getIntent().getIntArrayExtra(Constants.PAPER_SOURCE_INFO);
                break;
            case R.id.paper_type /*2131231314*/:
                this.paper_type_info = getIntent().getIntArrayExtra(Constants.PAPER_TYPE_INFO);
                break;
            case R.id.printdate /*2131231355*/:
                this.printdate_info = getIntent().getIntArrayExtra(Constants.PRINTDATE_INFO);
                break;
            case R.id.quality /*2131231392*/:
                this.quality_info = getIntent().getIntArrayExtra(Constants.PRINT_QUALITY_INFO);
                break;
        }
        this.sizeIndex = getIntent().getExtras().getInt("sizeIndex");
        this.typeIndex = getIntent().getExtras().getInt("typeIndex");
        this.isDocumentSetting = getIntent().getExtras().getBoolean("isDocumentSetting");
        this.mLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.setting_detail, (ViewGroup) null);
        buildElements();
        setContentView((View) this.mLayout);
        setActionBar(getTitle().toString(), true);
    }

    private void buildElements() {
        this.mBuilder = new PrinterInfoDetailBuilder(getBaseContext(), this.mLayout);
        this.mBuilder.build();
        this.mBuilder.setResource(Integer.valueOf(getIntent().getExtras().getInt("curValue")));
        this.mBuilder.refresh();
        EPLog.i("buildElements", "id = " + this.f405id);
        switch (this.f405id) {
            case R.id.apf_setting_layout /*2131230819*/:
                setTitle(R.string.apf_setting_title);
                this.mLookupTable = new MediaInfo.ApfState();
                ((PrinterInfoDetailBuilder) this.mBuilder).addPrinterInfo(new int[]{1, 0}, this.mLookupTable);
                break;
            case R.id.color /*2131230930*/:
                this.mLookupTable = new MediaInfo.Color();
                setTitle(getString(R.string.color));
                this.mHandler.sendEmptyMessage(6);
                break;
            case R.id.duplex /*2131231005*/:
                this.mLookupTable = new MediaInfo.Duplex();
                setTitle(getString(R.string.duplex));
                this.mHandler.sendEmptyMessage(7);
                break;
            case R.id.feed_direction /*2131231037*/:
                this.mLookupTable = new MediaInfo.FeedDirection();
                setTitle(getString(R.string.feed_direction));
                this.mHandler.sendEmptyMessage(8);
                break;
            case R.id.layout /*2131231158*/:
                this.mLookupTable = new LayoutEx();
                setTitle(getString(R.string.layout));
                this.mHandler.sendEmptyMessage(3);
                break;
            case R.id.paper_size /*2131231306*/:
                this.mLookupTable = new MediaInfo.PaperSize();
                setTitle(getString(R.string.paper_size));
                this.mHandler.sendEmptyMessage(1);
                break;
            case R.id.paper_source /*2131231311*/:
                this.mLookupTable = new MediaInfo.PaperSource();
                setTitle(getString(R.string.paper_source));
                this.mHandler.sendEmptyMessage(5);
                break;
            case R.id.paper_type /*2131231314*/:
                this.mLookupTable = new MediaInfo.PaperType();
                setTitle(getString(R.string.paper_type));
                this.mHandler.sendEmptyMessage(2);
                break;
            case R.id.printdate /*2131231355*/:
                this.mLookupTable = new MediaInfo.PrintDate();
                setTitle(getString(R.string.date_print));
                this.mHandler.sendEmptyMessage(18);
                break;
            case R.id.quality /*2131231392*/:
                this.mLookupTable = new MediaInfo.Quality();
                setTitle(getString(R.string.quality));
                this.mHandler.sendEmptyMessage(4);
                break;
            case R.id.sharpness_setting_layout /*2131231482*/:
                setTitle(R.string.sharpness_setting_title);
                this.mLookupTable = new MediaInfo.SharpnessState();
                ((PrinterInfoDetailBuilder) this.mBuilder).addPrinterInfo(new int[]{1, 0}, this.mLookupTable);
                break;
        }
        ((ListView) this.mLayout.findViewById(16908298)).setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
                Intent intent = new Intent();
                Bundle bundle = new Bundle();
                bundle.putInt("ID", PrinterInfoDetail.this.f405id);
                bundle.putInt("curValue", ((CommonDataKinds.PrinterInfo) PrinterInfoDetail.this.mBuilder.getData().elementAt(i)).getValue());
                bundle.putInt("INDEX", i);
                intent.putExtras(bundle);
                PrinterInfoDetail.this.setResult(-1, intent);
                PrinterInfoDetail.this.finish();
            }
        });
    }

    protected void onDestroy() {
        super.onDestroy();
        this.mBuilder.destructor();
        MediaInfo.AbstractInfo abstractInfo = this.mLookupTable;
        if (abstractInfo != null) {
            abstractInfo.destructor();
        }
    }
}
