Tabnine Logo
SpiceManager.execute
Code IndexAdd Tabnine to your IDE (free)

How to use
execute
method
in
com.octo.android.robospice.SpiceManager

Best Java code snippets using com.octo.android.robospice.SpiceManager.execute (Showing top 10 results out of 315)

origin: com.octo.android.robospice/robospice

/**
 * Execute a request, without using cache. No result from cache will be
 * returned. The method {@link SpiceRequest#loadDataFromNetwork()} will
 * always be invoked. The result will not be stored in cache.
 * @param request
 *            the request to execute.
 * @param requestListener
 *            the listener to notify when the request will finish.
 */
public <T> void execute(final SpiceRequest<T> request, final RequestListener<T> requestListener) {
  final CachedSpiceRequest<T> cachedSpiceRequest = new CachedSpiceRequest<T>(request, null, DurationInMillis.ALWAYS_RETURNED);
  execute(cachedSpiceRequest, requestListener);
}
origin: com.octo.android.robospice/robospice

/**
 * Execute a request. Before invoking the method
 * {@link SpiceRequest#loadDataFromNetwork()}, the cache will be checked :
 * if a result has been cached with the cache key <i>requestCacheKey</i>,
 * RoboSpice will consider the parameter <i>cacheExpiryDuration</i> to
 * determine whether the result in the cache is expired or not. If it is not
 * expired, then listeners will receive the data in cache. Otherwise, the
 * method {@link SpiceRequest#loadDataFromNetwork()} will be invoked and the
 * result will be stored in cache using the cache key
 * <i>requestCacheKey</i>.
 * @param request
 *            the request to execute
 * @param requestCacheKey
 *            the key used to store and retrieve the result of the request
 *            in the cache
 * @param cacheExpiryDuration
 *            duration in milliseconds after which the content of the cache
 *            will be considered to be expired.
 *            {@link DurationInMillis#ALWAYS_RETURNED} means data in cache
 *            is always returned if it exists.
 *            {@link DurationInMillis#ALWAYS_EXPIRED} means data in cache is
 *            never returned.(see {@link DurationInMillis})
 * @param requestListener
 *            the listener to notify when the request will finish
 */
public <T> void execute(final SpiceRequest<T> request, final Object requestCacheKey, final long cacheExpiryDuration, final RequestListener<T> requestListener) {
  final CachedSpiceRequest<T> cachedSpiceRequest = new CachedSpiceRequest<T>(request, requestCacheKey, cacheExpiryDuration);
  execute(cachedSpiceRequest, requestListener);
}
origin: com.octo.android.robospice/robospice

/**
 * @See #addListenerIfPending(Class, Object, PendingRequestListener)
 */
@Deprecated
public <T> void addListenerIfPending(final Class<T> clazz, final Object requestCacheKey, final RequestListener<T> requestListener) {
  final SpiceRequest<T> request = new SpiceRequest<T>(clazz) {
    @Override
    public T loadDataFromNetwork() throws Exception {
      return null;
    }
  };
  final CachedSpiceRequest<T> cachedSpiceRequest = new CachedSpiceRequest<T>(request, requestCacheKey, DurationInMillis.ALWAYS_EXPIRED);
  cachedSpiceRequest.setProcessable(false);
  execute(cachedSpiceRequest, requestListener);
}
origin: com.octo.android.robospice/robospice-sample

@Override
protected void onStart() {
  super.onStart();
  getJsonContentManager().execute(loremRequest, "lorem.txt", DurationInMillis.ONE_DAY, new LoremRequestListener());
  getJsonContentManager().execute(weatherRequest, "75000.json", DurationInMillis.ONE_DAY, new WeatherRequestJsonListener());
  getJsonContentManager().execute(weatherRequestXml, "75000.xml", DurationInMillis.ONE_DAY, new WeatherRequestXmlListener());
  getJsonContentManager().execute(imageRequest, "logo", DurationInMillis.ONE_DAY, new ImageRequestListener());
}
origin: n76/wifi_backend

@Override
public void onStart() {
  super.onStart();
  getSpiceManager().execute(
      new ResetSpiceRequest(getContext().getApplicationContext()),
      TAG,
      DurationInMillis.ALWAYS_EXPIRED,
      this
  );
}
origin: com.octo.android.robospice/robospice

/**
 * Adds some data to the cache, asynchronously.
 * @param clazz
 *            a super class or the class of data.
 * @param requestCacheKey
 *            the request cache key that data will be stored in.
 * @param data
 *            the data to store. Maybe null if supported by underlying
 *            ObjectPersister.
 * @param listener
 *            a listener that will be notified of this request's success or
 *            failure. May be null.
 */
public <U, T extends U> void putInCache(final Class<U> clazz, final Object requestCacheKey, final T data, RequestListener<U> listener) {
  @SuppressWarnings({ "unchecked", "rawtypes" })
  final SpiceRequest<U> spiceRequest = new SpiceRequest(clazz) {
    @Override
    public U loadDataFromNetwork() throws Exception {
      return data;
    }
  };
  CachedSpiceRequest<U> cachedSpiceRequest = new CachedSpiceRequest<U>(spiceRequest, requestCacheKey, DurationInMillis.ALWAYS_EXPIRED);
  cachedSpiceRequest.setOffline(true);
  execute(cachedSpiceRequest, listener);
}
origin: com.octo.android.robospice/robospice

/**
 * Gets data from cache, expired or not, and executes a request normaly.
 * Before invoking the method {@link SpiceRequest#loadDataFromNetwork()},
 * the cache will be checked : if a result has been cached with the cache
 * key <i>requestCacheKey</i>, RoboSpice will consider the parameter
 * <i>cacheExpiryDuration</i> to determine whether the result in the cache
 * is expired or not. If it is not expired, then listeners will receive the
 * data in cache only. If the result is absent or expired, then
 * {@link SpiceRequest#loadDataFromNetwork()} will be invoked and the result
 * will be stored in cache using the cache key <i>requestCacheKey</i>.
 * @param request
 *            the request to execute
 * @param requestCacheKey
 *            the key used to store and retrieve the result of the request
 *            in the cache
 * @param cacheExpiryDuration
 *            duration in milliseconds after which the content of the cache
 *            will be considered to be expired.
 *            {@link DurationInMillis#ALWAYS_RETURNED} means data in cache
 *            is always returned if it exists.
 *            {@link DurationInMillis#ALWAYS_EXPIRED} doesn't make much
 *            sense here.
 * @param requestListener
 *            the listener to notify when the request will finish
 */
public <T> void getFromCacheAndLoadFromNetworkIfExpired(final SpiceRequest<T> request, final Object requestCacheKey, final long cacheExpiryDuration, final RequestListener<T> requestListener) {
  final CachedSpiceRequest<T> cachedSpiceRequest = new CachedSpiceRequest<T>(request, requestCacheKey, cacheExpiryDuration);
  cachedSpiceRequest.setAcceptingDirtyCache(true);
  execute(cachedSpiceRequest, requestListener);
}
origin: com.octo.android.robospice/robospice

final CachedSpiceRequest<T> cachedSpiceRequest = new CachedSpiceRequest<T>(request, requestCacheKey, cacheExpiryDuration);
cachedSpiceRequest.setOffline(true);
execute(cachedSpiceRequest, requestListener);
origin: com.octo.android.robospice/robospice

/**
 * Cancel a pending request if it exists. If no such request exists, this
 * method does nothing. If a request identified by clazz and requestCacheKey
 * exists, it will be cancelled and its associated listeners will get
 * notified. This method is asynchronous.
 * @param clazz
 *            the class of the result of the pending request to look for.
 * @param requestCacheKey
 *            the cache key associated to the request's results.
 */
public <T> void cancel(final Class<T> clazz, final Object requestCacheKey) {
  final SpiceRequest<T> request = new SpiceRequest<T>(clazz) {
    @Override
    public T loadDataFromNetwork() throws Exception {
      return null;
    }
  };
  final CachedSpiceRequest<T> cachedSpiceRequest = new CachedSpiceRequest<T>(request, requestCacheKey, DurationInMillis.ALWAYS_EXPIRED);
  cachedSpiceRequest.setProcessable(false);
  cachedSpiceRequest.setOffline(true);
  cachedSpiceRequest.cancel();
  execute(cachedSpiceRequest, null);
}
origin: n76/wifi_backend

@Override
public void onStart() {
  super.onStart();
  if(!hasStartedRequest) {
    getSpiceManager().execute(getRequest(), getCacheKey(), DurationInMillis.ALWAYS_EXPIRED, this);
    hasStartedRequest = true;
  } else {
    getSpiceManager().addListenerIfPending(getRequest().getResultType(), getCacheKey(), this);
  }
}
com.octo.android.robospiceSpiceManagerexecute

Javadoc

Execute a request, put the result in cache and register listeners to notify when request is finished.

Popular methods of SpiceManager

  • shouldStop
    Stops the SpiceManager. It will unbind from SpiceService. All request listeners that had been regist
  • start
    Start the SpiceManager. It will bind asynchronously to the SpiceService.
  • <init>
    Creates a SpiceManager. Typically this occurs in the construction of an Activity or Fragment. This m
  • addListenerIfPending
  • addRequestListenerToListOfRequestListeners
  • addSpiceServiceListener
  • bindToService
  • checkServiceIsProperlyDeclaredInAndroidManifest
  • dontNotifyAnyRequestListenersInternal
    Remove all listeners of requests. All requests that have not been yet passed to the service will see
  • dontNotifyRequestListenersForRequestInternal
    Internal method to remove requests. If request has not been passed to the SpiceService yet, all list
  • executeCommand
  • getContextReference
  • executeCommand,
  • getContextReference,
  • getThreadCount,
  • isStarted,
  • match,
  • putInCache,
  • removeListenersOfAllPendingCachedRequests,
  • removeListenersOfCachedRequestToLaunch,
  • removeListenersOfPendingCachedRequest

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • startActivity (Activity)
  • onCreateOptionsMenu (Activity)
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Join (org.hibernate.mapping)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now