package com.bytedance.apm.agent.helper;

import X.AnonymousClass81J;
import com.bytedance.apm.agent.monitor.MonitorTool;
import com.bytedance.apm.agent.v2.InstructOperationSwitch;
import com.bytedance.covode.number.Covode;
import org.json.JSONObject;

public class PageShowCallback {
    static {
        Covode.recordClassIndex(23032);
    }

    public static void onPageShowHideAction(Object obj, boolean z) {
        String name;
        String str;
        if (InstructOperationSwitch.sUiSwitch) {
            if (obj instanceof String) {
                name = (String) obj;
            } else {
                name = obj.getClass().getName();
            }
            JSONObject jSONObject = new JSONObject();
            try {
                if (obj instanceof IPageMonitor) {
                    jSONObject.put("label", ((IPageMonitor) obj).getMonitorLabel());
                }
            } catch (Exception unused) {
            }
            if (z) {
                str = "page_show";
                if (AnonymousClass81J.LIZ.LIZJ().LJFF != null) {
                    AnonymousClass81J.LIZ.LIZJ();
                }
            } else {
                str = "page_hide";
            }
            MonitorTool.monitorUIAction(str, name, jSONObject);
        }
    }
}
