package epson.print.widgets;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AlphabetIndexer;
import android.widget.TextView;
import com.epson.mobilephone.common.wifidirect.WiFiControl;
import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
import epson.print.R;
import epson.print.MyPrinter;
import java.util.Vector;

public class PrinterInfoBuilder extends AbstractListBuilder {
    private static final int ACTIVE = 2;

    /* renamed from: IP */
    private static final int f408IP = 1;
    private static final int NAME = 0;
    public static final int PRINTER = 0;
    public static final int SCANNER = 1;
    String curPrinterId = null;
    private int kind = 0;

    public AlphabetIndexer getIndexer() {
        return null;
    }

    protected void notifyDataChange() {
    }

    public PrinterInfoBuilder(Context context, ViewGroup viewGroup, int i) {
        super(context, viewGroup);
        this.kind = i;
    }

    protected void buildData() {
        this.mData.clear();
    }

    public View buildViewHolder() {
        return this.mLayoutInflater.inflate(R.layout.printer_item, (ViewGroup) null);
    }

    public Vector<View> buildViewHolderContent(View view) {
        Vector<View> vector = new Vector<>();
        vector.add(view.findViewById(R.id.name));
        vector.add(view.findViewById(R.id.f336ip));
        vector.add(view.findViewById(R.id.active_icon));
        return vector;
    }

    public void buildViewHolderContentData(int i, Vector<View> vector, Vector<Object> vector2) {
        int i2 = 0;
        ((TextView) vector.elementAt(0)).setText(((MyPrinter) vector2.elementAt(i)).getName());
        if (this.kind != 1) {
            if (WiFiControl.ConnectType.NONE.equals(WiFiDirectManager.getConnectType(this.mContext, ((MyPrinter) vector2.elementAt(i)).getIp()))) {
                View elementAt = vector.elementAt(2);
                if (!((MyPrinter) vector2.elementAt(i)).getPrinterId().equals(this.curPrinterId)) {
                    i2 = 8;
                }
                elementAt.setVisibility(i2);
            } else {
                View elementAt2 = vector.elementAt(2);
                if (!((MyPrinter) vector2.elementAt(i)).getIp().equals(this.curPrinterId)) {
                    i2 = 8;
                }
                elementAt2.setVisibility(i2);
            }
        } else if (WiFiControl.ConnectType.NONE.equals(WiFiDirectManager.getConnectType(this.mContext, ((MyPrinter) vector2.elementAt(i)).getIp()))) {
            String scannerId = ((MyPrinter) vector2.elementAt(i)).getScannerId();
            if (scannerId != null) {
                View elementAt3 = vector.elementAt(2);
                if (!scannerId.equals(this.curPrinterId)) {
                    i2 = 8;
                }
                elementAt3.setVisibility(i2);
            } else {
                vector.elementAt(2).setVisibility(8);
            }
        } else {
            String ip = ((MyPrinter) vector2.elementAt(i)).getIp();
            if (ip != null) {
                View elementAt4 = vector.elementAt(2);
                if (!ip.equals(this.curPrinterId)) {
                    i2 = 8;
                }
                elementAt4.setVisibility(i2);
            } else {
                vector.elementAt(2).setVisibility(8);
            }
        }
        String ip2 = ((MyPrinter) vector2.elementAt(i)).getIp();
        if (WiFiControl.ConnectType.NONE.equals(WiFiDirectManager.getConnectType(this.mContext, ip2))) {
            String commonDeviceName = ((MyPrinter) vector2.elementAt(i)).getCommonDeviceName();
            if (commonDeviceName == null || commonDeviceName.isEmpty()) {
                ((TextView) vector.elementAt(1)).setText(ip2);
                return;
            }
            ((TextView) vector.elementAt(1)).setText(commonDeviceName + " (" + ip2 + ")");
            return;
        }
        ((TextView) vector.elementAt(1)).setText(WiFiDirectManager.getConnectString(this.mContext, ip2, ((MyPrinter) vector2.elementAt(i)).getPrinterId()));
    }

    public void setResource(Object obj) {
        this.curPrinterId = (String) obj;
    }

    public void addPrinter(String[] strArr) {
        String str = "";
        if (strArr.length == 5) {
            str = strArr[4];
        }
        MyPrinter myPrinter = new MyPrinter(strArr[1], strArr[2], strArr[3], str);
        myPrinter.setPrinterIndex(Integer.parseInt(strArr[0]));
        this.mData.add(myPrinter);
        this.mAdapter.notifyDataSetChanged();
    }

    public void addPrinter(MyPrinter myPrinter) {
        this.mData.add(myPrinter);
        this.mAdapter.notifyDataSetChanged();
    }

    public void replacePrinter(MyPrinter myPrinter, int i) {
        getData().setElementAt(myPrinter, i);
        this.mAdapter.notifyDataSetChanged();
    }
}
