Esempio n. 1
0
  /**
   * Specify the content URI to execute the command against.
   *
   * <p>
   *
   * <p>Must be called before trying to use {@link #execute()} or {@link #executeAsync(int,
   * Callback)}
   *
   * @param uri required. The content URI to target.
   * @return the current instance.
   * @since 1.0
   */
  @NonNull
  public RC onUri(@NonNull Uri uri) {
    Preconditions.argumentNotNull(uri, "Uri can't be null");

    mUri = uri;

    //noinspection unchecked
    return (RC) this;
  }
Esempio n. 2
0
  protected BaseResolverCommand(@NonNull ContentResolver contentResolver) {
    Preconditions.argumentNotNull(contentResolver, "ContentResolver can't be null");

    synchronized (BaseResolverCommand.class) {
      if (sLooper == null) {
        HandlerThread workerThread = new HandlerThread("ResolverCommandWorker");
        workerThread.start();

        sLooper = workerThread.getLooper();
      }
    }

    //noinspection unchecked
    mWorkerHandler = new WorkerHandler(sLooper, this);
    mResolverRef = new WeakReference<>(contentResolver);
  }
Esempio n. 3
0
 /**
  * Validate the state of the command before execution.
  *
  * @throws IllegalStateException if the command can't be executed with the current state.
  * @since 1.0
  */
 @CallSuper
 protected void validateStatePreExecute() {
   Preconditions.stateNotNull(mUri, "Uri not set. Did you call onUri()?");
 }