//
// SamsoN - utilities for playn clients and servers
// Copyright (c) 2014, Cupric - All rights reserved.
// http://github.com/cupric/samson/blob/master/LICENSE

package samson;

import java.util.List;

import com.google.common.collect.Lists;

import org.lwjgl.opengl.Display;

/**
 * Notifier for debugging notifications. Issues a log message printout via an Interval.
 */
public class JavaNotifications extends Notifications
{
    @Override
    public void cancelAll () {
        for (Interval interval : _scheduled) {
            interval.cancel();
        }
        _scheduled.clear();
    }

    @Override
    protected Handle schedule (long when, final Builder builder) {
        final Interval interval = new Interval(Interval.PLAYN) {
            @Override
            public void expired () {
                dispatch(builder._data, Display.isActive());
                _scheduled.remove(this);
            }
        };

        interval.schedule(Math.max(0, when - System.currentTimeMillis()));
        _scheduled.add(interval);

        return new Handle() {
            @Override
            public void cancel() {
                interval.cancel();
                _scheduled.remove(interval);
            }
        };
    }

    protected List<Interval> _scheduled = Lists.newArrayList();
}

@@ -196,16 +196,38 @@
 il.List;
+%0Aimport java.util.Map;
 %0A%0Aimport
@@ -670,22 +670,16 @@
 g when, 
-final 
 Builder 
@@ -688,16 +688,122 @@
 ilder) %7B
+%0A        final String message = builder._message;%0A        final Map%3CString, String%3E data = builder._data;%0A
 %0A       
@@ -846,22 +846,8 @@
 val(
-Interval.PLAYN
 ) %7B%0A
@@ -901,24 +901,24 @@
 xpired () %7B%0A
+
             
@@ -930,25 +930,16 @@
 ispatch(
-builder._
 data, Di

Clean up a little and don't store a final reference to the builder.