package o; import android.text.Editable; import android.text.TextUtils; import android.view.KeyEvent; import android.view.View; import android.widget.EditText; import android.widget.TextView; import com.google.android.material.timepicker.ChipTextInputComboView; /* loaded from: classes2.dex */ final class SpB implements TextView.OnEditorActionListener, View.OnKeyListener { final ChipTextInputComboView b; private final VPp c; final ChipTextInputComboView d; private boolean e = false; /* JADX INFO: Access modifiers changed from: package-private */ public SpB(ChipTextInputComboView chipTextInputComboView, ChipTextInputComboView chipTextInputComboView2, VPp vPp) { this.b = chipTextInputComboView; this.d = chipTextInputComboView2; this.c = vPp; } private void e(int i) { this.d.setChecked(i == 12); this.b.setChecked(i == 10); this.c.f = i; } @Override // android.widget.TextView.OnEditorActionListener public final boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { boolean z = i == 5; if (z) { e(12); } return z; } @Override // android.view.View.OnKeyListener public final boolean onKey(View view, int i, KeyEvent keyEvent) { if (this.e) { return false; } boolean z = true; this.e = true; EditText editText = (EditText) view; if (this.c.f == 12) { if (i == 67 && keyEvent.getAction() == 0 && TextUtils.isEmpty(editText.getText())) { e(10); } else { if (editText.getSelectionStart() == 0 && editText.length() == 2) { editText.getText().clear(); } z = false; } } else { Editable text = editText.getText(); if (text != null) { if (i >= 7 && i <= 16 && keyEvent.getAction() == 1 && editText.getSelectionStart() == 2 && text.length() == 2) { e(12); } else if (editText.getSelectionStart() == 0 && editText.length() == 2) { editText.getText().clear(); } } z = false; } this.e = false; return z; } }