package defpackage;

import android.R;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.speech.RecognitionListener;
import android.util.Log;
import android.widget.EditText;
import android.widget.ImageButton;
import androidx.media3.container.NalUnitUtil;
import com.strmr.ps.ui.search.SearchFragment;
import java.util.ArrayList;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\b\n\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Led8;", "Landroid/speech/RecognitionListener;", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
public final class ed8 implements RecognitionListener {
    public final /* synthetic */ SearchFragment a;

    public ed8(SearchFragment searchFragment) {
        this.a = searchFragment;
    }

    @Override // android.speech.RecognitionListener
    public final void onBeginningOfSpeech() {
    }

    @Override // android.speech.RecognitionListener
    public final void onBufferReceived(byte[] bArr) {
    }

    @Override // android.speech.RecognitionListener
    public final void onEndOfSpeech() {
        SearchFragment searchFragment = this.a;
        searchFragment.r = false;
        ImageButton imageButton = searchFragment.i;
        if (imageButton != null) {
            imageButton.setBackgroundTintList(searchFragment.s);
        } else {
            cr4.n("voiceButton");
            throw null;
        }
    }

    @Override // android.speech.RecognitionListener
    public final void onError(int i) {
        SearchFragment searchFragment = this.a;
        searchFragment.r = false;
        ImageButton imageButton = searchFragment.i;
        if (imageButton == null) {
            cr4.n("voiceButton");
            throw null;
        }
        imageButton.setBackgroundTintList(searchFragment.s);
        Log.w("SearchFragment", "Speech recognition error: " + i);
    }

    @Override // android.speech.RecognitionListener
    public final void onEvent(int i, Bundle bundle) {
    }

    @Override // android.speech.RecognitionListener
    public final void onPartialResults(Bundle bundle) {
    }

    @Override // android.speech.RecognitionListener
    public final void onReadyForSpeech(Bundle bundle) {
        SearchFragment searchFragment = this.a;
        searchFragment.r = true;
        ImageButton imageButton = searchFragment.i;
        if (imageButton != null) {
            imageButton.setBackgroundTintList(ColorStateList.valueOf(sf1.getColor(searchFragment.requireContext(), R.color.holo_red_dark)));
        } else {
            cr4.n("voiceButton");
            throw null;
        }
    }

    @Override // android.speech.RecognitionListener
    public final void onResults(Bundle bundle) {
        SearchFragment searchFragment = this.a;
        searchFragment.r = false;
        ImageButton imageButton = searchFragment.i;
        if (imageButton == null) {
            cr4.n("voiceButton");
            throw null;
        }
        imageButton.setBackgroundTintList(searchFragment.s);
        ArrayList<String> stringArrayList = bundle != null ? bundle.getStringArrayList("results_recognition") : null;
        String str = stringArrayList != null ? (String) y41.ab(stringArrayList) : null;
        if (str == null || n89.ab(str)) {
            return;
        }
        EditText editText = searchFragment.f;
        if (editText == null) {
            cr4.n("searchField");
            throw null;
        }
        editText.setText(str);
        EditText editText2 = searchFragment.f;
        if (editText2 == null) {
            cr4.n("searchField");
            throw null;
        }
        editText2.setSelection(str.length());
        searchFragment.n();
    }

    @Override // android.speech.RecognitionListener
    public final void onRmsChanged(float f) {
    }
}
