// Path: goro/src/main/java/com/stanfy/enroscar/goro/BoundGoro.java
// static class BoundGoroImpl extends BoundGoro implements ServiceConnection {
// 
//   /** Instance of the context used to bind to GoroService. */
//   private final Context context;
// 
//   /** Disconnection handler. */
//   private final OnUnexpectedDisconnection disconnectionHandler;
// 
//   // Modified in the main thread only.
//   private boolean unbindRequested;
// 
//   BoundGoroImpl(final Context context, final OnUnexpectedDisconnection disconnectionHandler) {
//     this.context = context;
//     this.disconnectionHandler = disconnectionHandler;
//   }
// 
//   @Override
//   public void bind() {
//     unbindRequested = false;
//     GoroService.bind(context, this);
//   }
// 
//   @Override
//   public void unbind() {
//     if (updateDelegate(null)) {
//       GoroService.unbind(context, this);
//       unbindRequested = false;
//     } else {
//       unbindRequested = true;
//     }
//   }
// 
//   @Override
//   public void onServiceConnected(final ComponentName name, final IBinder binder) {
//     updateDelegate(Goro.from(binder));
//     if (unbindRequested) {
//       // If unbind is requested before we get a real connection, unbind here, after delegating all buffered calls.
//       unbind();
//     }
//   }
// 
//   @Override
//   public void onServiceDisconnected(final ComponentName name) {
//     if (updateDelegate(null)) {
//       /*
//         It's the case when service was stopped by a system server.
//         It can happen when user presses a stop button in application settings (in running apps section).
//         Sometimes this happens on application update.
//        */
//       if (disconnectionHandler == null) {
//         bind();
//       } else {
//         disconnectionHandler.onServiceDisconnected(this);
//       }
//     }
//   }
// 
// }


import android.content.Context;
import android.os.IBinder;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import static com.stanfy.enroscar.goro.BoundGoro.BoundGoroImpl;
package com.stanfy.enroscar.goro;




/**
 * Handles tasks in multiple queues.
 */
public abstract class Goro {

  /** Default queue name. */
  public static final String DEFAULT_QUEUE = "default";

  /**
   * Gives access to Goro instance that is provided by a service.
   * @param binder Goro service binder
   * @return Goro instance provided by the service
   */
  public static Goro from(final IBinder binder) {
    if (binder instanceof GoroService.GoroBinder) {
      return ((GoroService.GoroBinder) binder).goro();
    }
    throw new IllegalArgumentException("Cannot get Goro from " + binder);
  }

  /**
   * Creates a new Goro instance which uses {@link android.os.AsyncTask#THREAD_POOL_EXECUTOR}
   * to delegate tasks on Post-Honeycomb devices or create a separate thread pool on earlier
   * Android versions.
   * @return instance of Goro
   */
  public static Goro create() {
    return new GoroImpl();
  }

  /**
   * Creates a new Goro instance which uses the specified executor to delegate tasks.
   * @param delegateExecutor executor Goro delegates tasks to
   * @return instance of Goro
   */
  public static Goro createWithDelegate(final Executor delegateExecutor) {
    GoroImpl goro = new GoroImpl();
    goro.queues.setDelegateExecutor(delegateExecutor);
    return goro;
  }

  /**
   * Creates a Goro implementation that binds to {@link com.stanfy.enroscar.goro.GoroService}
   * in order to run scheduled tasks in service context.
   * <p>
   *   This method is functionally identical to
   * </p>
   * <pre>
   *   BoundGoro goro = Goro.bindWith(context, new BoundGoro.OnUnexpectedDisconnection() {
   *     public void onServiceDisconnected(BoundGoro goro) {
   *       goro.bind();
   *     }
   *   });
   * </pre>
   * @param context context that will bind to the service
   * @return Goro implementation that binds to {@link GoroService}.
   * @see #bindWith(Context, BoundGoro.OnUnexpectedDisconnection)
   */
  public static BoundGoro bindAndAutoReconnectWith(final Context context) {
    if (context == null) {
      throw new IllegalArgumentException("Context cannot be null");
    }
// Path: goro/src/main/java/com/stanfy/enroscar/goro/BoundGoro.java
// static class BoundGoroImpl extends BoundGoro implements ServiceConnection {
// 
//   /** Instance of the context used to bind to GoroService. */
//   private final Context context;
// 
//   /** Disconnection handler. */
//   private final OnUnexpectedDisconnection disconnectionHandler;
// 
//   // Modified in the main thread only.
//   private boolean unbindRequested;
// 
//   BoundGoroImpl(final Context context, final OnUnexpectedDisconnection disconnectionHandler) {
//     this.context = context;
//     this.disconnectionHandler = disconnectionHandler;
//   }
// 
//   @Override
//   public void bind() {
//     unbindRequested = false;
//     GoroService.bind(context, this);
//   }
// 
//   @Override
//   public void unbind() {
//     if (updateDelegate(null)) {
//       GoroService.unbind(context, this);
//       unbindRequested = false;
//     } else {
//       unbindRequested = true;
//     }
//   }
// 
//   @Override
//   public void onServiceConnected(final ComponentName name, final IBinder binder) {
//     updateDelegate(Goro.from(binder));
//     if (unbindRequested) {
//       // If unbind is requested before we get a real connection, unbind here, after delegating all buffered calls.
//       unbind();
//     }
//   }
// 
//   @Override
//   public void onServiceDisconnected(final ComponentName name) {
//     if (updateDelegate(null)) {
//       /*
//         It's the case when service was stopped by a system server.
//         It can happen when user presses a stop button in application settings (in running apps section).
//         Sometimes this happens on application update.
//        */
//       if (disconnectionHandler == null) {
//         bind();
//       } else {
//         disconnectionHandler.onServiceDisconnected(this);
//       }
//     }
//   }
// 
// }


// Path: goro/src/main/java/com/stanfy/enroscar/goro/Goro.java
import android.content.Context;
import android.os.IBinder;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import static com.stanfy.enroscar.goro.BoundGoro.BoundGoroImpl;

package com.stanfy.enroscar.goro;




/**
 * Handles tasks in multiple queues.
 */
public abstract class Goro {

  /** Default queue name. */
  public static final String DEFAULT_QUEUE = "default";

  /**
   * Gives access to Goro instance that is provided by a service.
   * @param binder Goro service binder
   * @return Goro instance provided by the service
   */
  public static Goro from(final IBinder binder) {
    if (binder instanceof GoroService.GoroBinder) {
      return ((GoroService.GoroBinder) binder).goro();
    }
    throw new IllegalArgumentException("Cannot get Goro from " + binder);
  }

  /**
   * Creates a new Goro instance which uses {@link android.os.AsyncTask#THREAD_POOL_EXECUTOR}
   * to delegate tasks on Post-Honeycomb devices or create a separate thread pool on earlier
   * Android versions.
   * @return instance of Goro
   */
  public static Goro create() {
    return new GoroImpl();
  }

  /**
   * Creates a new Goro instance which uses the specified executor to delegate tasks.
   * @param delegateExecutor executor Goro delegates tasks to
   * @return instance of Goro
   */
  public static Goro createWithDelegate(final Executor delegateExecutor) {
    GoroImpl goro = new GoroImpl();
    goro.queues.setDelegateExecutor(delegateExecutor);
    return goro;
  }

  /**
   * Creates a Goro implementation that binds to {@link com.stanfy.enroscar.goro.GoroService}
   * in order to run scheduled tasks in service context.
   * <p>
   *   This method is functionally identical to
   * </p>
   * <pre>
   *   BoundGoro goro = Goro.bindWith(context, new BoundGoro.OnUnexpectedDisconnection() {
   *     public void onServiceDisconnected(BoundGoro goro) {
   *       goro.bind();
   *     }
   *   });
   * </pre>
   * @param context context that will bind to the service
   * @return Goro implementation that binds to {@link GoroService}.
   * @see #bindWith(Context, BoundGoro.OnUnexpectedDisconnection)
   */
  public static BoundGoro bindAndAutoReconnectWith(final Context context) {
    if (context == null) {
      throw new IllegalArgumentException("Context cannot be null");
    }
    return new BoundGoroImpl(context, null);