package com.strmr.ps.ui.contextmenu;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;
import androidx.media3.container.NalUnitUtil;
import androidx.media3.exoplayer.upstream.CmcdData;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.strmr.ps.R;
import defpackage.ah;
import defpackage.co;
import defpackage.cr4;
import defpackage.sq3;
import defpackage.xf1;
import defpackage.ya;
import java.util.List;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0018\u00002\u00020\u0001:\u0001\u0002¨\u0006\u0003"}, d2 = {"Lcom/strmr/ps/ui/contextmenu/f;", "Landroid/app/Dialog;", CmcdData.OBJECT_TYPE_AUDIO_ONLY, "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
public final class f extends Dialog {
    public static final /* synthetic */ int e = 0;
    public final String a;
    public final List b;
    public final sq3 c;
    public boolean d;

    @Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Lcom/strmr/ps/ui/contextmenu/f$a;", "", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class a {
        public static void a(Context context, String str, List list, sq3 sq3Var) {
            cr4.g(context, "context");
            cr4.g(str, "title");
            new f(context, str, list, sq3Var).show();
        }
    }

    public f(Context context, String str, List list, sq3 sq3Var) {
        super(context, R.style.ContextMenuDialogTheme);
        this.a = str;
        this.b = list;
        this.c = sq3Var;
    }

    @Override // android.app.Dialog, android.view.Window.Callback
    public final boolean dispatchKeyEvent(KeyEvent keyEvent) {
        cr4.g(keyEvent, "event");
        int keyCode = keyEvent.getKeyCode();
        if ((keyCode != 23 && keyCode != 66) || this.d) {
            return super.dispatchKeyEvent(keyEvent);
        }
        if (keyEvent.getAction() == 1) {
            this.d = true;
        }
        return true;
    }

    /* JADX WARN: Removed duplicated region for block: B:10:0x0027  */
    @Override // android.app.Dialog
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void onCreate(Bundle bundle) {
        View childAt;
        super.onCreate(bundle);
        requestWindowFeature(1);
        setContentView(R.layout.dialog_context_menu);
        View viewFindViewById = findViewById(android.R.id.content);
        if (viewFindViewById == null) {
            childAt = null;
        } else {
            ViewGroup viewGroup = viewFindViewById instanceof ViewGroup ? (ViewGroup) viewFindViewById : null;
            if (viewGroup != null) {
                childAt = viewGroup.getChildAt(0);
            }
        }
        Drawable background = childAt != null ? childAt.getBackground() : null;
        if (background instanceof LayerDrawable) {
            LayerDrawable layerDrawable = (LayerDrawable) background;
            if (layerDrawable.getNumberOfLayers() >= 4) {
                Drawable drawable = layerDrawable.getDrawable(3);
                if (drawable instanceof GradientDrawable) {
                    TypedValue typedValue = new TypedValue();
                    getContext().getTheme().resolveAttribute(R.attr.colorAccentPrimary, typedValue, true);
                    int i = typedValue.data;
                    int i2 = 16777215 & i;
                    ((GradientDrawable) drawable).setColors(new int[]{i2, i, i2});
                }
            }
        }
        ((TextView) findViewById(R.id.context_menu_title)).setText(this.a);
        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.context_menu_actions);
        getContext();
        recyclerView.setLayoutManager(new LinearLayoutManager());
        recyclerView.setAdapter(new e(this.b, new co(this, 9), new ah(this, 6)));
        recyclerView.post(new xf1(recyclerView, 0));
        setOnKeyListener(new ya(this, 1));
    }

    @Override // android.app.Dialog
    public final void onStart() {
        super.onStart();
        Window window = getWindow();
        if (window != null) {
            window.setLayout(getContext().getResources().getDimensionPixelSize(R.dimen.context_menu_width), -2);
        }
    }
}
