Android Open Source - client-android Async Task Result






From Project

Back to project page client-android.

License

The source code is released under:

Apache License

If you think the Android project client-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.qmonix.sdk.utils;
//w w w .j  a va 2 s . co m

/**
 * Class that holds information for AsyncTask.doInBackground() result. It might be either
 * a valid result or an exception.
 */
public class AsyncTaskResult<T> {

  private T result;
  private Exception error;


  /**
   * Constructs a valid result object.
   *
   * @param result AsyncTask.doInBackground() method result.
   */
  public AsyncTaskResult(T result) {
    this.result = result;
  }

  /**
   * Constructs a result object that indicates an exception.
   *
   * @param error exception object that was thrown during AsyncTask.doInBackground().
   */
  public AsyncTaskResult(Exception error) {
    this.error = error;
  }

  public T getResult() {
    return this.result;
  }

  public Exception getError() {
    return this.error;
  }

  /**
   * Checks if result oject is an exception.
   *
   * @return true if object is an excetion, otherwise false.
   */
  public boolean isException() {
    if (this.error != null){
      return true;

    } else {
      return false;
    }
  }

  /**
   * Checks if object is a valid result. If the result was null it will return false,
   * no matter that no exception was raised. To be sure better use isException()
   * to check if AsyncTask.doInBackground() failed or not.
   *
   * @return true if object is a valid result, otherise false.
   */
  public boolean isValidResult() {
    if (this.result != null) {
      return true;

    } else{
      return false;
    }
  }
}




Java Source Code List

com.qmonix.sample.basic.MainActivity.java
com.qmonix.sdk.EventDispatchHandler.java
com.qmonix.sdk.EventDispatcher.java
com.qmonix.sdk.EventMessage.java
com.qmonix.sdk.Event.java
com.qmonix.sdk.FireableTimingEvent.java
com.qmonix.sdk.HttpEventDispatcher.java
com.qmonix.sdk.LogEventDispatcher.java
com.qmonix.sdk.QLog.java
com.qmonix.sdk.TimingEvent.java
com.qmonix.sdk.Tracker.java
com.qmonix.sdk.VolumeEvent.java
com.qmonix.sdk.helpers.HttpHelper.java
com.qmonix.sdk.helpers.exceptions.HttpHelperException.java
com.qmonix.sdk.utils.AsyncTaskResult.java
com.qmonix.sdk.utils.Utils.java