All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ioc.commons.impl.android.integration.service.CommandQueue Maven / Gradle / Ivy

package org.ioc.commons.impl.android.integration.service;

import org.ioc.commons.utils.FormatterLogger;
import org.ioc.commons.utils.logs.IFormatterLogger.Level;

public class CommandQueue {
	
	/*
	 * TODO: Por hacer colas
	 */

	private static FormatterLogger logger = FormatterLogger.getLogger(CommandQueue.class);
	private static Level logLevel = Level.DEBUG;

//	private List queue = new ArrayList();
	private boolean requestInProgress = false;
	private boolean cancelNextRequestsOnFail;

//	public boolean hasPendingRequests() {
//		return !queue.isEmpty();
//	}

	public CommandQueue() {
		// Nothing
	}

	public CommandQueue(boolean cancelNextRequestsOnFail) {
		this.setCancelNextRequestsOnFail(cancelNextRequestsOnFail);
	}

//	public  void fireOrQueue(Scheduler.ScheduledCommand request) {
//		if (!requestInProgress) {
//			requestInProgress = true;
//			logger.log(logLevel, "There are no request in progress. Calling fire()...");
//
//			request.execute();
//		} else {
//			logger.log(logLevel, "There are request in progress. Queueing request.");
//			queue.add(request);
//		}
//	}

	public boolean isCancelNextRequestsOnFail() {
		return cancelNextRequestsOnFail;
	}

	public void setCancelNextRequestsOnFail(boolean cancelNextRequestsOnFail) {
		this.cancelNextRequestsOnFail = cancelNextRequestsOnFail;
	}

	public void fireNext() {
//		this.requestInProgress = false;
//		Scheduler.ScheduledCommand nextRequest = (!queue.isEmpty() ? queue.remove(0) : null);
//		if (nextRequest != null) {
//			fireOrQueue(nextRequest);
//		}
	}

	public static Level getLogLevel() {
		return logLevel;
	}

	public static void setLogLevel(Level logLevel) {
		CommandQueue.logLevel = logLevel;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy