package xyz.stream.view;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
import android.os.Looper;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import androidx.core.view.m3;
import androidx.core.view.s1;
import androidx.emoji2.text.v;
import java.util.Objects;

/* JADX INFO: loaded from: classes3.dex */
public class CustomLoading {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final Handler f36250b = new Handler(Looper.getMainLooper());

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static volatile CustomLoading f36251c;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public e.m f36252a;

    public static void a(Context context, e.m mVar) {
        Window window = mVar.getWindow();
        Objects.requireNonNull(window);
        WindowManager.LayoutParams attributes = window.getAttributes();
        if (ViewRuntime.isPhone()) {
            attributes.width = -1;
            attributes.height = -1;
            mVar.getWindow().setBackgroundDrawableResource(android.R.color.black);
        } else {
            attributes.width = (int) TypedValue.applyDimension(1, 1920.0f, context.getResources().getDisplayMetrics());
            attributes.height = (int) TypedValue.applyDimension(1, 1920.0f, context.getResources().getDisplayMetrics());
            mVar.getWindow().setBackgroundDrawable(new ColorDrawable(0));
        }
        mVar.getWindow().setAttributes(attributes);
        mVar.getWindow().getDecorView().setPadding(0, 0, 0, 0);
        View decorView = window.getDecorView();
        o6.b.B(window, false);
        m3 m3Var = new m3(window, decorView);
        m3Var.a(7);
        m3Var.b();
        s1.setOnApplyWindowInsetsListener(decorView, new xyz.netfly.viewmodel.a(18));
    }

    public static e.m b(Context context, String str) {
        if (context == null) {
            return null;
        }
        e.l lVar = new e.l(context, R.style.CustomLoading);
        LayoutInflater layoutInflaterFrom = LayoutInflater.from(context);
        View viewInflate = layoutInflaterFrom.inflate(R.layout.custom_loading, (ViewGroup) null);
        if (ViewRuntime.isTablet()) {
            viewInflate = layoutInflaterFrom.inflate(R.layout.custom_loading_pad, (ViewGroup) null);
        } else if (ViewRuntime.isPhone()) {
            viewInflate = layoutInflaterFrom.inflate(R.layout.custom_loading_mobile, (ViewGroup) null);
        }
        ((TextView) viewInflate.findViewById(R.id.progress_message)).setText(str);
        lVar.setView(viewInflate);
        lVar.f25255a.f25211k = true;
        return lVar.create();
    }

    public static CustomLoading getInstance() {
        if (f36251c == null) {
            synchronized (CustomLoading.class) {
                try {
                    if (f36251c == null) {
                        f36251c = new CustomLoading();
                    }
                } finally {
                }
            }
        }
        return f36251c;
    }

    public void dismiss() {
        f36250b.post(new p000if.e(this, 20));
    }

    public void show(Context context, String str) {
        f36250b.post(new v(this, context, str, 26));
    }
}
