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

import android.app.Activity;
import android.os.Looper;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import java.util.Collections;

/* JADX INFO: loaded from: classes2.dex */
public final class ux extends zv1 {
    public final Activity Q;
    public d70 R;
    public ImageView S;
    public LinearLayout T;
    public final zx U;
    public PopupWindow V;
    public RelativeLayout W;
    public ViewGroup X;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public String f17410d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f17411e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f17412f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f17413g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f17414h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f17415i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f17416j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f17417k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final Object f17418l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final x50 f17419m;

    static {
        androidx.collection.g gVar = new androidx.collection.g(7);
        Collections.addAll(gVar, "top-left", "top-right", "top-center", "center", "bottom-left", "bottom-right", "bottom-center");
        Collections.unmodifiableSet(gVar);
    }

    public ux(x50 x50Var, zx zxVar) {
        super(x50Var, "resize", 11);
        this.f17410d = "top-right";
        this.f17411e = true;
        this.f17412f = 0;
        this.f17413g = 0;
        this.f17414h = -1;
        this.f17415i = 0;
        this.f17416j = 0;
        this.f17417k = -1;
        this.f17418l = new Object();
        this.f17419m = x50Var;
        this.Q = x50Var.zzj();
        this.U = zxVar;
    }

    public final void j(boolean z10) {
        synchronized (this.f17418l) {
            try {
                if (this.V != null) {
                    if (!((Boolean) n7.y.f31093e.f31096c.b(ao.f8774ac)).booleanValue() || Looper.getMainLooper().getThread() == Thread.currentThread()) {
                        k(z10);
                    } else {
                        b30.f9364f.e(new n5.q(3, this, z10));
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final void k(boolean z10) {
        tn tnVar = ao.f8791bc;
        n7.y yVar = n7.y.f31093e;
        boolean zBooleanValue = ((Boolean) yVar.f31096c.b(tnVar)).booleanValue();
        x50 x50Var = this.f17419m;
        if (zBooleanValue) {
            this.W.removeView((View) x50Var);
            this.V.dismiss();
        } else {
            this.V.dismiss();
            this.W.removeView((View) x50Var);
        }
        tn tnVar2 = ao.f8807cc;
        yn ynVar = yVar.f31096c;
        if (((Boolean) ynVar.b(tnVar2)).booleanValue()) {
            View view = (View) x50Var;
            ViewParent parent = view.getParent();
            if (parent instanceof ViewGroup) {
                ((ViewGroup) parent).removeView(view);
            }
        }
        ViewGroup viewGroup = this.X;
        if (viewGroup != null) {
            viewGroup.removeView(this.S);
            if (((Boolean) ynVar.b(ao.f8824dc)).booleanValue()) {
                try {
                    this.X.addView((View) x50Var);
                    x50Var.G(this.R);
                } catch (IllegalStateException e10) {
                    m7.n.C.f30469h.d("MraidCallResizeHandler.collapseInternal", e10);
                }
            } else {
                this.X.addView((View) x50Var);
                x50Var.G(this.R);
            }
        }
        if (z10) {
            h("default");
            zx zxVar = this.U;
            if (zxVar != null) {
                ((dh0) zxVar).zzb();
            }
        }
        this.V = null;
        this.W = null;
        this.X = null;
        this.T = null;
    }
}
