package com.ss.android.ugc.aweme.commercialize.widget;

import X.0CB;
import X.0CH;
import X.1hK;
import X.2UX;
import X.2nK;
import X.33g;
import X.6Is;
import X.C2080Kn1;
import X.C2850KzR;
import X.C2853KzU;
import X.C2855KzW;
import X.C2868Kzj;
import X.C2870Kzl;
import X.C2873Kzo;
import X.M12;
import android.app.Activity;
import android.widget.FrameLayout;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.router.SmartRouter;
import com.ss.android.ugc.aweme.arch.widgets.base.DataCenter;
import java.lang.ref.WeakReference;
import java.util.Map;
import kotlin.h.b.n;

public final class CommonWebPageWidget extends AbsAdFeedWidget implements 6Is {
    public static boolean LJIIJJI;
    public static final C2853KzU LJIIL = new C2853KzU((byte) 0);
    public C2850KzR LIZ;
    public long LJII;
    public final C2855KzW LJIIIIZZ = new C2855KzW(this);
    public final C2868Kzj LJIIIZ = new C2868Kzj();
    public final C2873Kzo LJIIJ = new C2873Kzo();

    static {
        Covode.recordClassIndex(60176);
    }

    public final void onStateChanged(0CH r1, 0CB r2) {
        super.onStateChanged(r1, r2);
    }

    public final void onPause() {
        LIZ(System.currentTimeMillis() - this.LJII);
        super.onPause();
    }

    public final void onResume() {
        this.LJII = System.currentTimeMillis();
        super.onResume();
    }

    public final void LJ() {
        super.LJ();
        DataCenter dataCenter = this.LJ;
        if (dataCenter != null) {
            dataCenter.LIZ("ad_feed_on_page_selected", this);
            dataCenter.LIZ("ad_feed_on_page_unselected", this);
            dataCenter.LIZ("ad_video_on_resume_play", this);
            dataCenter.LIZ("video_params", this);
        }
    }

    public final void onCreate() {
        super.onCreate();
        M12.LIZ((Object) this);
        C2870Kzl.LIZ = new WeakReference<>(this);
        if (!C2870Kzl.LIZIZ) {
            SmartRouter.addInterceptor(new OverlaySchemaProxy$setCurrentWidget$1());
            C2870Kzl.LIZIZ = true;
        }
    }

    public final /* synthetic */ void onChanged(Object obj) {
        onChanged((33g) obj);
    }

    public final void LIZ(long j) {
        if (this.LIZ != null) {
            2UX r1 = new 2UX();
            r1.LIZ("duration", j);
            2nK.LIZ("h5_stay_time", r1.LIZ);
        }
    }

    public final void LIZ(33g r13) {
        String str;
        Fragment fragment;
        1hK activity;
        1hK activity2;
        MethodCollector.i(2298);
        super.onChanged(r13);
        if (r13 == null || (str = r13.LIZ) == null) {
            MethodCollector.o(2298);
            return;
        }
        int hashCode = str.hashCode();
        if (hashCode != -1540531799) {
            if (hashCode == 2040441990 && str.equals("ad_video_on_resume_play")) {
                if (this.LIZ == null) {
                    MethodCollector.o(2298);
                    return;
                }
                Fragment fragment2 = this.LJIILL;
                if (!(fragment2 == null || (activity2 = fragment2.getActivity()) == null)) {
                    C2853KzU kzU = LJIIL;
                    n.LIZIZ(activity2, "");
                    M12.LIZ((Object) activity2);
                    C2850KzR LIZIZ = kzU.LIZIZ(activity2);
                    if (LIZIZ != null && LIZIZ.LIZ()) {
                        kzU.LIZ(-1);
                    }
                    MethodCollector.o(2298);
                    return;
                }
            }
        } else if (!(!str.equals("ad_feed_on_page_unselected") || this.LIZ == null || (fragment = this.LJIILL) == null || (activity = fragment.getActivity()) == null)) {
            C2853KzU kzU2 = LJIIL;
            M12.LIZ((Object) activity);
            C2850KzR LIZIZ2 = kzU2.LIZIZ(activity);
            if (LIZIZ2 != null) {
                C2080Kn1.LIZ((C2080Kn1) LIZIZ2.LIZ(2131368688), "about:blank", false, (Map) null, false, 14);
                LIZIZ2.LJIIIIZZ.LIZLLL();
                FrameLayout LIZ2 = kzU2.LIZ((Activity) activity);
                if (LIZ2 != null) {
                    LIZ2.removeView(LIZIZ2);
                }
            }
            this.LIZ = null;
            MethodCollector.o(2298);
            return;
        }
        MethodCollector.o(2298);
    }
}
