Java Code Examples for com.badlogic.gdx.utils.Timer#Task

The following examples show how to use com.badlogic.gdx.utils.Timer#Task . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ToastManager.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
/** Displays toast. Toast will be displayed for given amount of seconds. */
public Toast show (final Toast toast, float timeSec) {
	Table toastMainTable = toast.getMainTable();
	if (toastMainTable.getStage() != null) {
		remove(toast);
	}
	toasts.add(toast);

	toast.setToastManager(this);
	toast.fadeIn();
	toastMainTable.pack();
	root.addActor(toastMainTable);

	updateToastsPositions();

	if (timeSec > 0) {
		Timer.Task fadeOutTask = new Timer.Task() {
			@Override
			public void run () {
				toast.fadeOut();
				timersTasks.remove(toast);
			}
		};
		timersTasks.put(toast, fadeOutTask);
		Timer.schedule(fadeOutTask, timeSec);
	}
	return toast;
}
 
Example 2
Source File: ToastManager.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Removes toast from screen.
 * @return true when toast was removed, false otherwise
 */
public boolean remove (Toast toast) {
	boolean removed = toasts.removeValue(toast, true);
	if (removed) {
		toast.getMainTable().remove();
		Timer.Task timerTask = timersTasks.remove(toast);
		if (timerTask != null) timerTask.cancel();
		updateToastsPositions();
	}
	return removed;
}
 
Example 3
Source File: ToastManager.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
public void clear () {
	for (Toast toast : toasts) {
		toast.getMainTable().remove();
	}
	toasts.clear();
	for (Timer.Task task : timersTasks.values()) {
		task.cancel();
	}
	timersTasks.clear();
	updateToastsPositions();
}
 
Example 4
Source File: ToastManager.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
/** Displays toast. Toast will be displayed for given amount of seconds. */
public void show (final Toast toast, float timeSec) {
	Table toastMainTable = toast.getMainTable();
	if (toastMainTable.getStage() != null) {
		remove(toast);
	}
	toasts.add(toast);

	toast.setToastManager(this);
	toast.fadeIn();
	toastMainTable.pack();
	root.addActor(toastMainTable);

	updateToastsPositions();

	if (timeSec > 0) {
		Timer.Task fadeOutTask = new Timer.Task() {
			@Override
			public void run () {
				toast.fadeOut();
				timersTasks.remove(toast);
			}
		};
		timersTasks.put(toast, fadeOutTask);
		Timer.schedule(fadeOutTask, timeSec);
	}
}
 
Example 5
Source File: ToastManager.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
/**
 * Removes toast from screen.
 * @return true when toast was removed, false otherwise
 */
public boolean remove (Toast toast) {
	boolean removed = toasts.removeValue(toast, true);
	if (removed) {
		toast.getMainTable().remove();
		Timer.Task timerTask = timersTasks.remove(toast);
		if (timerTask != null) timerTask.cancel();
		updateToastsPositions();
	}
	return removed;
}
 
Example 6
Source File: ToastManager.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
public void clear () {
	for (Toast toast : toasts) {
		toast.getMainTable().remove();
	}
	toasts.clear();
	for (Timer.Task task : timersTasks.values()) {
		task.cancel();
	}
	timersTasks.clear();
	updateToastsPositions();
}