package com.ifpdos.factorytest;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcel;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.cvte.vman.VmanMiddleWare;
import com.cvte.vman.listener.OnTxbListener;
import com.cvte.vman.types.EnumTxbKeyType;
import com.cvte.vman.types.EnumTxbMaterialType;
import com.ifpdos.factorytest.util.GridViewGroup;
import com.ifpdos.factorytest.util.StringUtil;

/* JADX INFO: loaded from: classes.dex */
public class TxbOqcBxTestActivity extends Activity {
    static final String TAG = "TxbOqcBxTestActivity";
    private EnumTxbMaterialType currentMaterialType;
    String testItem;
    private int totalTestCount = 0;
    private int successTestCount = 0;
    private int testTimes = 1;
    private int mClickCount = 0;
    private int needTestTimes = 0;

    @Override // android.app.Activity
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.totalTestCount = 0;
        this.successTestCount = 0;
        this.mClickCount = 0;
        this.testTimes = getIntent().getIntExtra(StringUtil.TXB_TEST_TIMES, 1);
        this.testItem = getIntent().getStringExtra(StringUtil.TEST_ITEM_INTENT);
        this.needTestTimes = this.testTimes * 220;
        setContentView(R.layout.activity_txb_oqc_bx_test);
        final GridViewGroup gridViewGroup = (GridViewGroup) findViewById(R.id.grid_view_group);
        TextView textView = (TextView) findViewById(R.id.txb_current_test);
        textView.setText(this.testItem);
        textView.setTextSize(50.0f);
        GridViewGroup.setLimitCount(this.testTimes);
        gridViewGroup.addChildViews();
        startRegisterTxbListener();
        String str = this.testItem;
        str.hashCode();
        switch (str) {
            case "PEN_TIP_TEST":
                this.currentMaterialType = EnumTxbMaterialType.TXB_MATERIAL_PENPOINT;
                break;
            case "FINGER_TEST":
                this.currentMaterialType = EnumTxbMaterialType.TXB_MATERIAL_FINGER;
                break;
            case "PEN_TAIL_TEST":
                this.currentMaterialType = EnumTxbMaterialType.TXB_MATERIAL_PEN_TAIL;
                break;
        }
        ((Button) findViewById(R.id.txb_back)).setOnClickListener(new View.OnClickListener() { // from class: com.ifpdos.factorytest.TxbOqcBxTestActivity$$ExternalSyntheticLambda0
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                this.f$0.lambda$onCreate$0(view);
            }
        });
        ((Button) findViewById(R.id.txb_clear)).setOnClickListener(new View.OnClickListener() { // from class: com.ifpdos.factorytest.TxbOqcBxTestActivity$$ExternalSyntheticLambda1
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                this.f$0.lambda$onCreate$1(gridViewGroup, view);
            }
        });
        ((Button) findViewById(R.id.txb_clear_and_back)).setOnClickListener(new View.OnClickListener() { // from class: com.ifpdos.factorytest.TxbOqcBxTestActivity$$ExternalSyntheticLambda2
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                this.f$0.lambda$onCreate$2(gridViewGroup, view);
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public /* synthetic */ void lambda$onCreate$0(View view) {
        if (checkFinish()) {
            Intent intent = new Intent();
            intent.putExtra("totalTestCount", this.totalTestCount);
            intent.putExtra("successTestCount", this.successTestCount);
            setResult(2, intent);
            finish();
            return;
        }
        Toast.makeText(this, getString(R.string.test_not_completed_do_not_return) + "[" + this.mClickCount + "/" + this.needTestTimes + "]", 0).show();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public /* synthetic */ void lambda$onCreate$1(GridViewGroup gridViewGroup, View view) {
        gridViewGroup.clearAllTestView();
        this.totalTestCount = 0;
        this.successTestCount = 0;
        this.mClickCount = 0;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public /* synthetic */ void lambda$onCreate$2(GridViewGroup gridViewGroup, View view) {
        gridViewGroup.clearAllTestView();
        this.totalTestCount = 0;
        this.successTestCount = 0;
        Intent intent = new Intent();
        intent.putExtra("totalTestCount", this.totalTestCount);
        intent.putExtra("successTestCount", this.successTestCount);
        setResult(2, intent);
        finish();
    }

    private boolean checkFinish() {
        Log.d(TAG, "checkFinish: needTestTimes = " + this.needTestTimes + " mClickCount = " + this.mClickCount);
        return this.mClickCount >= this.needTestTimes;
    }

    @Override // android.app.Activity, android.view.Window.Callback
    public boolean dispatchTouchEvent(MotionEvent motionEvent) {
        if (motionEvent.getAction() == 0) {
            this.mClickCount++;
            Log.d(TAG, "dispatchTouchEvent, mClickCount = " + this.mClickCount);
        }
        return super.dispatchTouchEvent(motionEvent);
    }

    @Override // android.app.Activity
    protected void onDestroy() {
        super.onDestroy();
    }

    private void startRegisterTxbListener() {
        VmanMiddleWare.getInstance().registerListener(new OnTxbListener() { // from class: com.ifpdos.factorytest.TxbOqcBxTestActivity.1
            @Override // com.cvte.vman.listener.OnTxbListener
            public void onTxbKeycodeNotify(EnumTxbKeyType enumTxbKeyType) {
            }

            @Override // com.cvte.vman.listener.OnTxbListener
            public void onTxbMaterialNotify(EnumTxbMaterialType enumTxbMaterialType) {
                Log.d(TxbOqcBxTestActivity.TAG, "onTxbMaterialNotify: " + enumTxbMaterialType);
                TxbOqcBxTestActivity.this.totalTestCount++;
                if (enumTxbMaterialType == TxbOqcBxTestActivity.this.currentMaterialType) {
                    TxbOqcBxTestActivity.this.successTestCount++;
                }
                Log.d(TxbOqcBxTestActivity.TAG, "onTxbMaterialNotify---> rate = ( " + TxbOqcBxTestActivity.this.successTestCount + "," + TxbOqcBxTestActivity.this.totalTestCount + ")");
            }

            @Override // com.cvte.vman.listener.OnTxbListener
            public void onTxbSignalAmplitudeNotify(int[] iArr, int i) {
                Log.d(TxbOqcBxTestActivity.TAG, "onTxbSignalAmplitudeNotify,length: " + i);
            }

            @Override // com.cvte.vman.listener.OnTxbListener, com.cvte.vman.listener.IVmanListener
            public void notifyMessage(int i, int i2, int i3, Parcel parcel) {
                super.notifyMessage(i, i2, i3, parcel);
            }

            @Override // com.cvte.vman.listener.OnTxbListener, com.cvte.vman.listener.IVmanListener
            public int[] getMessageList() {
                return super.getMessageList();
            }
        });
    }
}
