Android Open Source - sloop Data Collection Result






From Project

Back to project page sloop.

License

The source code is released under:

NON-LICENSE The Sloop data-browser source code is hereby released into the Public Domain. The original author, David Megginson, Megginson Technologies Ltd., and Acclar Open Ltd. provide no warranty:...

If you think the Android project sloop 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.megginson.sloop.ui;
//  www .j a  va  2s. com
import com.megginson.sloop.activities.MainActivity;
import com.megginson.sloop.model.DataCollection;

/**
 * The result of loading a {@link DataCollectionImpl}
 * 
 * The {@link DataCollectionLoader} class uses this class to represent its
 * result
 * 
 * Because the loader task runs on a background thread, we can't simply throw an
 * exception from it on error; instead, we need to wrap our result (a
 * {@link DataCollectionImpl}) in a class like this, together with information about
 * error status, then check it in the handler method in the main thread when the
 * load is complete.
 * 
 * @author David Megginson
 * @see DataCollectionLoader#loadInBackground()
 * @see MainActivity#onLoadFinished(android.content.Loader,
 *      DataCollectionResult)
 */
public class DataCollectionResult {

  private DataCollection mDataCollection;
  
  private String mRedirectUrl;
  
  private Throwable mThrowable;
  
  /**
   * Create the result of a successful load.
   * 
   * @param dataCollection
   *            The data collection to return.
   */
  public DataCollectionResult(DataCollection dataCollection) {
    mDataCollection = dataCollection;
    mRedirectUrl = null;
    mThrowable = null;
  }
  
  /**
   * Result for a load that needs to redirect to a non-CSV URL.
   * 
   * @param redirectUrl the URL to send to the browser.
   */
  public DataCollectionResult(String redirectUrl) {
    mDataCollection = null;
    mRedirectUrl = redirectUrl;
    mThrowable = null;
  }

  /**
   * Create the result of an unsuccessful load.
   * 
   * @param errorMessage
   *            The error message.
   */
  public DataCollectionResult(Throwable throwable) {
    mDataCollection = null;
    mRedirectUrl = null;
    mThrowable = throwable;
  }

  /**
   * Test whether the load was successful.
   * 
   * @return true if there is a {@link DataCollectionImpl} available; false if
   *         there is an error message.
   */
  public boolean hasError() {
    return mThrowable != null;
  }

  /**
   * Get the data collection from a successful load.
   * 
   * @return A data collection if the load was successful; null otherwise.
   * @see #hasError()
   */
  public DataCollection getDataCollection() {
    return mDataCollection;
  }
  
  public String getRedirectUrl() {
    return mRedirectUrl;
  }

  /**
   * Get the error message from an unsuccessful load.
   * 
   * @return An error message if the load was unsuccessful; null otherwise.
   * @see #hasError()
   */
  public Throwable getThrowable() {
    return mThrowable;
  }

}




Java Source Code List

com.megginson.sloop.activities.ActivitiesUtil.java
com.megginson.sloop.activities.AddressActionProvider.java
com.megginson.sloop.activities.BookmarkEditActivity.java
com.megginson.sloop.activities.BookmarkListActivity.java
com.megginson.sloop.activities.InfoBarFragment.java
com.megginson.sloop.activities.MainActivity.java
com.megginson.sloop.activities.MainDisplayFragment.java
com.megginson.sloop.activities.TextFilterFragment.java
com.megginson.sloop.activities.package-info.java
com.megginson.sloop.model.Bookmark.java
com.megginson.sloop.model.DataCollection.java
com.megginson.sloop.model.DataEntry.java
com.megginson.sloop.model.DataRecord.java
com.megginson.sloop.model.Util.java
com.megginson.sloop.model.ValueFilter.java
com.megginson.sloop.model.impl.ContainsStringFilter.java
com.megginson.sloop.model.impl.DataCollectionIO.java
com.megginson.sloop.model.impl.DataCollectionImpl.java
com.megginson.sloop.model.impl.DataEntryImpl.java
com.megginson.sloop.model.impl.DataRecordImpl.java
com.megginson.sloop.model.impl.EqualsStringFilter.java
com.megginson.sloop.model.impl.package-info.java
com.megginson.sloop.model.package-info.java
com.megginson.sloop.ui.BookmarkListAdapter.java
com.megginson.sloop.ui.DataCollectionLoader.java
com.megginson.sloop.ui.DataCollectionPagerAdapter.java
com.megginson.sloop.ui.DataCollectionResult.java
com.megginson.sloop.ui.DataRecordFragment.java
com.megginson.sloop.ui.DataRecordListAdapter.java
com.megginson.sloop.ui.package-info.java