void (List<Object> timings, String parentName, long startTimeUnixNano) { if (!items.isEmpty()) { throw new IllegalStateException("addTimings must be not called if some events were already added using API"); } if (timings.isEmpty()) { return; } ActivityImpl parent = new ActivityImpl(parentName, (long)timings.get(1), null, null); parent.setEnd(System.nanoTime()); for (int i = 0; i < timings.size(); i += 2) { long start = (long)timings.get(i + 1); if (start < startTime) { startTime = start; startTimeUnixNanoDiff = startTimeUnixNano - start; } ActivityImpl activity = new ActivityImpl((String)timings.get(i), start, parent, null); activity.setEnd(i == timings.size() - 2 ? parent.getEnd() : (long)timings.get(i + 3)); items.add(activity); } items.add(parent); }