package com.bytedance.ies.sdk.widgets;

import X.0c0;
import X.2HN;
import X.2Pr;
import X.C1430G2l;
import X.C2888GjR;
import X.CwZ;
import X.LWx;
import X.LsC;
import com.bytedance.android.widget.Widget;
import com.bytedance.covode.number.Covode;
import java.util.HashMap;
import java.util.Map;

public final class WidgetCreateTimeUtil implements C2888GjR {
    public final LsC<Widget, 2Pr> onWidgetLoadedListener;
    public final Map<String, Object> widgetCreateTimeMap;

    static {
        Covode.recordClassIndex(30555);
    }

    public WidgetCreateTimeUtil() {
        this((LsC) null, 1, (2HN) null);
    }

    public final void clear() {
        this.widgetCreateTimeMap.clear();
    }

    public final void send() {
        0c0.LIZ("ttlive_widget_create_cost_time", 0, LWx.LIZ(CwZ.LIZ("widget_time", this.widgetCreateTimeMap)), 1);
    }

    public WidgetCreateTimeUtil(LsC<? super Widget, 2Pr> lsC) {
        this.onWidgetLoadedListener = lsC;
        this.widgetCreateTimeMap = new HashMap();
    }

    public final boolean needUploadTime(Widget widget) {
        Boolean bool = null;
        if (!(widget instanceof LiveRecyclableWidget)) {
            widget = null;
        }
        LiveRecyclableWidget liveRecyclableWidget = (LiveRecyclableWidget) widget;
        if (liveRecyclableWidget != null) {
            bool = Boolean.valueOf(liveRecyclableWidget.isInitialized());
        }
        return C1430G2l.LIZJ(bool);
    }

    public final void onLoad(Widget widget, long j) {
        Class<?> cls;
        String simpleName;
        Map<String, Object> map = this.widgetCreateTimeMap;
        if (widget != null && (cls = widget.getClass()) != null && (simpleName = cls.getSimpleName()) != null) {
            map.put(simpleName, Long.valueOf(j));
            LsC<Widget, 2Pr> lsC = this.onWidgetLoadedListener;
            if (lsC != null) {
                lsC.invoke(widget);
            }
        }
    }

    /* JADX INFO: this call moved to the top of the method (can break code semantics) */
    public /* synthetic */ WidgetCreateTimeUtil(LsC lsC, int i, 2HN r4) {
        this((i & 1) != 0 ? null : lsC);
    }
}
