package com.google.android.gms.ads.internal.overlay;

import android.R;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.google.android.gms.internal.ads.ao;
import com.google.android.gms.internal.ads.tn;
import n7.x;
import n7.y;

/* JADX INFO: loaded from: classes2.dex */
public final class zzu extends FrameLayout implements View.OnClickListener {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ImageButton f7957a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final f f7958b;

    /* JADX WARN: Code restructure failed: missing block: B:33:0x005e, code lost:
    
        r0 = null;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public zzu(Context context, q qVar, @Nullable f fVar) {
        Resources resourcesZzf;
        super(context);
        this.f7958b = fVar;
        setOnClickListener(this);
        ImageButton imageButton = new ImageButton(context);
        this.f7957a = imageButton;
        String str = (String) y.f31093e.f31096c.b(ao.f9177z1);
        if (TextUtils.isEmpty(str) || "default".equals(str) || (resourcesZzf = m7.n.C.f30469h.zzf()) == null) {
            imageButton.setImageResource(R.drawable.btn_dialog);
        } else {
            try {
            } catch (Resources.NotFoundException unused) {
                q7.j.a("Close button resource not found, falling back to default.");
            }
            Drawable drawable = "white".equals(str) ? resourcesZzf.getDrawable(k7.a.admob_close_button_white_circle_black_cross) : "black".equals(str) ? resourcesZzf.getDrawable(k7.a.admob_close_button_black_circle_white_cross) : null;
            if (drawable == null) {
                imageButton.setImageResource(R.drawable.btn_dialog);
            } else {
                imageButton.setImageDrawable(drawable);
                imageButton.setScaleType(ImageView.ScaleType.CENTER);
            }
        }
        this.f7957a.setBackgroundColor(0);
        this.f7957a.setOnClickListener(this);
        ImageButton imageButton2 = this.f7957a;
        q7.e eVar = x.f31085g.f31086a;
        imageButton2.setPadding(q7.e.g(context.getResources().getDisplayMetrics(), qVar.f7951a), q7.e.g(context.getResources().getDisplayMetrics(), 0), q7.e.g(context.getResources().getDisplayMetrics(), qVar.f7952b), q7.e.g(context.getResources().getDisplayMetrics(), qVar.f7953c));
        this.f7957a.setContentDescription("Interstitial close button");
        addView(this.f7957a, new FrameLayout.LayoutParams(q7.e.g(context.getResources().getDisplayMetrics(), qVar.f7954d + qVar.f7951a + qVar.f7952b), q7.e.g(context.getResources().getDisplayMetrics(), qVar.f7954d + qVar.f7953c), 17));
        tn tnVar = ao.A1;
        y yVar = y.f31093e;
        long jLongValue = ((Long) yVar.f31096c.b(tnVar)).longValue();
        if (jLongValue <= 0) {
            return;
        }
        l.e eVar2 = ((Boolean) yVar.f31096c.b(ao.B1)).booleanValue() ? new l.e(this) : null;
        this.f7957a.setAlpha(0.0f);
        this.f7957a.animate().alpha(1.0f).setDuration(jLongValue).setListener(eVar2);
    }

    @Override // android.view.View.OnClickListener
    public final void onClick(View view) {
        f fVar = this.f7958b;
        if (fVar != null) {
            l lVar = (l) fVar;
            lVar.Y = 2;
            lVar.f7928b.finish();
        }
    }
}
