package com.bytedance.sdk.openadsdk.core.vt;

import android.annotation.SuppressLint;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import java.util.ArrayList;
import java.util.List;

/* JADX INFO: loaded from: classes2.dex */
public class yz {

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private static volatile yz f7327lb;
    private static int ro;
    private final List<ajl> fm = new ArrayList();

    public static yz fm() {
        if (f7327lb == null) {
            synchronized (yz.class) {
                try {
                    if (f7327lb == null) {
                        f7327lb = new yz();
                    }
                } catch (Throwable th) {
                    throw th;
                }
            }
        }
        return f7327lb;
    }

    public int lb() {
        return this.fm.size();
    }

    @Nullable
    public ajl ro() {
        ajl ajlVarRemove;
        if (lb() > 0 && (ajlVarRemove = this.fm.remove(0)) != null) {
            return ajlVarRemove;
        }
        return null;
    }

    @SuppressLint({"SetJavaScriptEnabled"})
    public void lb(ajl ajlVar) {
        if (ajlVar == null || ajlVar.getWebView() == null) {
            return;
        }
        if (ajlVar.getParent() != null) {
            ((ViewGroup) ajlVar.getParent()).removeView(ajlVar);
        }
        try {
            ajlVar.removeAllViews();
            ajlVar.wsy();
            ajlVar.setWebChromeClient(null);
            ajlVar.setWebViewClient(null);
            ajlVar.setDownloadListener(null);
            ajlVar.setDefaultTextEncodingName("UTF-8");
            ajlVar.setAllowFileAccess(false);
            ajlVar.setJavaScriptEnabled(true);
            ajlVar.setCacheMode(-1);
            ajlVar.setDatabaseEnabled(true);
            ajlVar.setSupportZoom(false);
            ajlVar.getWebView().setLayerType(0, null);
            ajlVar.setBackgroundColor(0);
            ajlVar.getWebView().setHorizontalScrollBarEnabled(false);
            ajlVar.getWebView().setHorizontalScrollbarOverlay(false);
            ajlVar.getWebView().setVerticalScrollBarEnabled(false);
            ajlVar.getWebView().setVerticalScrollbarOverlay(false);
            com.bytedance.sdk.openadsdk.core.widget.fm.yz.fm(ajlVar);
            ajlVar.dsz();
            ajlVar.setMixedContentMode(0);
        } catch (Exception unused) {
        }
    }

    public void ro(ajl ajlVar) {
        if (ajlVar != null) {
            if (this.fm.size() >= ro) {
                ajlVar.fhx();
            } else {
                if (this.fm.contains(ajlVar)) {
                    return;
                }
                lb(ajlVar);
                this.fm.add(ajlVar);
            }
        }
    }

    @UiThread
    public void fm(ajl ajlVar) {
        if (ajlVar != null) {
            ro(ajlVar);
        }
    }
}
