code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
@Override public void run() { dontNotifyRequestListenersForRequestInternal(request); }
Disable request listeners notifications for a specific request.<br/> None of the listeners associated to this request will be called when request will finish.<br/> This method will ask (asynchronously) to the {@link SpiceService} to remove listeners if requests have already been sent to the {@link SpiceService} if the request has already been sent to the service. Otherwise, it will just remove listeners before passing the request to the {@link SpiceService}. Calling this method doesn't prevent request from being executed (and put in cache) but will remove request's listeners notification. @param request Request for which listeners are to unregistered.
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
protected void dontNotifyRequestListenersForRequestInternal(final SpiceRequest<?> request) { lockSendRequestsToService.lock(); try { final boolean requestNotPassedToServiceYet = removeListenersOfCachedRequestToLaunch(request); Ln.v("Removed from requests to launch list : " + requestNotPassedToServiceYet); // if the request was already passed to service, bind to // service and // unregister listeners. if (!requestNotPassedToServiceYet) { removeListenersOfPendingCachedRequest(request); Ln.v("Removed from pending requests list"); } } catch (final InterruptedException e) { Ln.e(e, "Interrupted while removing listeners."); } finally { lockSendRequestsToService.unlock(); } }
Internal method to remove requests. If request has not been passed to the {@link SpiceService} yet, all listeners are unregistered locally before being passed to the service. Otherwise, it will asynchronously ask to the {@link SpiceService} to remove the listeners of the request being processed. @param request Request for which listeners are to unregistered.
dontNotifyRequestListenersForRequestInternal
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
private boolean removeListenersOfCachedRequestToLaunch(final SpiceRequest<?> request) { synchronized (mapRequestToLaunchToRequestListener) { for (final CachedSpiceRequest<?> cachedSpiceRequest : mapRequestToLaunchToRequestListener.keySet()) { if (match(cachedSpiceRequest, request)) { final Set<RequestListener<?>> setRequestListeners = mapRequestToLaunchToRequestListener.get(cachedSpiceRequest); setRequestListeners.clear(); return true; } } return false; } }
Remove all listeners of a request that has not yet been passed to the {@link SpiceService}. @param request the request for which listeners must be unregistered. @return a boolean indicating if the request could be found inside the list of requests to be launched. If false, the request was already passed to the service.
removeListenersOfCachedRequestToLaunch
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
private void removeListenersOfPendingCachedRequest(final SpiceRequest<?> request) throws InterruptedException { synchronized (mapPendingRequestToRequestListener) { for (final CachedSpiceRequest<?> cachedSpiceRequest : mapPendingRequestToRequestListener.keySet()) { if (match(cachedSpiceRequest, request)) { waitForServiceToBeBound(); if (spiceService == null) { return; } final Set<RequestListener<?>> setRequestListeners = mapPendingRequestToRequestListener.get(cachedSpiceRequest); spiceService.dontNotifyRequestListenersForRequest(cachedSpiceRequest, setRequestListeners); mapPendingRequestToRequestListener.remove(cachedSpiceRequest); break; } } } }
Remove all listeners of a request that may have already been passed to the {@link SpiceService}. If the request has already been passed to the {@link SpiceService}, the method will bind to the service and ask it to remove listeners. @param request the request for which listeners must be unregistered.
removeListenersOfPendingCachedRequest
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public void dontNotifyAnyRequestListeners() { executorService.execute(new Runnable() { @Override public void run() { dontNotifyAnyRequestListenersInternal(); } }); }
Disable request listeners notifications for all requests. <br/> Should be called in {@link Activity#onStop}
dontNotifyAnyRequestListeners
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
@Override public void run() { dontNotifyAnyRequestListenersInternal(); }
Disable request listeners notifications for all requests. <br/> Should be called in {@link Activity#onStop}
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
protected void dontNotifyAnyRequestListenersInternal() { lockSendRequestsToService.lock(); try { if (spiceService == null) { return; } synchronized (mapRequestToLaunchToRequestListener) { if (!mapRequestToLaunchToRequestListener.isEmpty()) { for (final CachedSpiceRequest<?> cachedSpiceRequest : mapRequestToLaunchToRequestListener.keySet()) { final Set<RequestListener<?>> setRequestListeners = mapRequestToLaunchToRequestListener.get(cachedSpiceRequest); if (setRequestListeners != null) { Ln.d("Removing listeners of request to launch : " + cachedSpiceRequest.toString() + " : " + setRequestListeners.size()); spiceService.dontNotifyRequestListenersForRequest(cachedSpiceRequest, setRequestListeners); } } } mapRequestToLaunchToRequestListener.clear(); } Ln.v("Cleared listeners of all requests to launch"); removeListenersOfAllPendingCachedRequests(); } catch (final InterruptedException e) { Ln.e(e, "Interrupted while removing listeners."); } finally { lockSendRequestsToService.unlock(); } }
Remove all listeners of requests. All requests that have not been yet passed to the service will see their of listeners cleaned. For all requests that have been passed to the service, we ask the service to remove their listeners.
dontNotifyAnyRequestListenersInternal
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
private void removeListenersOfAllPendingCachedRequests() throws InterruptedException { synchronized (mapPendingRequestToRequestListener) { if (!mapPendingRequestToRequestListener.isEmpty()) { for (final CachedSpiceRequest<?> cachedSpiceRequest : mapPendingRequestToRequestListener.keySet()) { final Set<RequestListener<?>> setRequestListeners = mapPendingRequestToRequestListener.get(cachedSpiceRequest); if (setRequestListeners != null) { Ln.d("Removing listeners of pending request : " + cachedSpiceRequest.toString() + " : " + setRequestListeners.size()); spiceService.dontNotifyRequestListenersForRequest(cachedSpiceRequest, setRequestListeners); } } mapPendingRequestToRequestListener.clear(); } } Ln.v("Cleared listeners of all pending requests"); }
Asynchronously ask service to remove all listeners of pending requests. @throws InterruptedException in case service binding fails.
removeListenersOfAllPendingCachedRequests
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
private boolean match(final CachedSpiceRequest<?> cachedSpiceRequest, final SpiceRequest<?> spiceRequest) { if (spiceRequest instanceof CachedSpiceRequest) { return spiceRequest == cachedSpiceRequest; } else { return cachedSpiceRequest.getSpiceRequest() == spiceRequest; } }
Wether or not a given {@link CachedSpiceRequest} matches a {@link SpiceRequest}. @param cachedSpiceRequest the request know by the {@link SpiceManager}. @param spiceRequest the request that we wish to remove notification for. @return true if {@link CachedSpiceRequest} matches contentRequest.
match
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public <T> Future<T> getDataFromCache(final Class<T> clazz, final Object cacheKey) throws CacheLoadingException { return executeCommand(new GetDataFromCacheCommand<T>(this, clazz, cacheKey)); }
Get some data previously saved in cache with key <i>requestCacheKey</i>. This method doesn't perform any network processing, it just checks if there are previously saved data. Don't call this method in the main thread because you could block it. Instead, use the asynchronous version of this method: {@link #getFromCache(Class, Object, long, RequestListener)}. @param clazz the class of the result to retrieve from cache. @param cacheKey the key used to store and retrieve the result of the request in the cache @return a future object that will hold data in cache. Calling get on this future will block until the data is actually effectively taken from cache. @throws CacheLoadingException Exception thrown when a problem occurs while loading data from cache.
getDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public <T> Future<T> putDataInCache(final Object cacheKey, final T data) throws CacheSavingException, CacheCreationException { return executeCommand(new PutDataInCacheCommand<T>(this, data, cacheKey)); }
Put some new data in cache using cache key <i>requestCacheKey</i>. This method doesn't perform any network processing, it just data in cache, erasing any previsouly saved date in cache using the same class and key. Don't call this method in the main thread because you could block it. Instead, use the asynchronous version of this method: {@link #putInCache(Class, Object, Object)}. @param cacheKey the key used to store and retrieve the result of the request in the cache @param data the data to be saved in cache. @return the data has it has been saved by an ObjectPersister in cache. @throws CacheLoadingException Exception thrown when a problem occurs while loading data from cache.
putDataInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public Future<Boolean> isDataInCache(Class<?> clazz, final Object cacheKey, long cacheExpiryDuration) throws CacheCreationException { return executeCommand(new IsDataInCacheCommand(this, clazz, cacheKey, cacheExpiryDuration)); }
Tests whether some data is present in cache or not. @param clazz the class of the result to retrieve from cache. @param cacheKey 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}) @return the data has it has been saved by an ObjectPersister in cache. @throws CacheCreationException Exception thrown when a problem occurs while looking for data in cache.
isDataInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public Future<Date> getDateOfDataInCache(Class<?> clazz, final Object cacheKey) throws CacheCreationException { return executeCommand(new GetDateOfDataInCacheCommand(this, clazz, cacheKey)); }
Returns the last date of storage of a given data into the cache. @param clazz the class of the result to retrieve from cache. @param cacheKey the key used to store and retrieve the result of the request in the cache @return the date at which data has been stored in cache. Null if no such data is in Cache. @throws CacheLoadingException Exception thrown when a problem occurs while loading data from cache.
getDateOfDataInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public <T> Future<?> removeDataFromCache(final Class<T> clazz, final Object cacheKey) { if (clazz == null || cacheKey == null) { throw new IllegalArgumentException("Both parameters must be non null."); } return executeCommand(new RemoveDataFromCacheCommand(this, clazz, cacheKey)); }
Remove some specific content from cache @param clazz the Type of data you want to remove from cache @param cacheKey the key of the object in cache
removeDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public <T> Future<?> removeDataFromCache(final Class<T> clazz) { if (clazz == null) { throw new IllegalArgumentException("Clazz must be non null."); } return executeCommand(new RemoveDataClassFromCacheCommand(this, clazz)); }
Remove some specific content from cache @param clazz the type of data you want to remove from cache.
removeDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public Future<?> removeAllDataFromCache() { return executeCommand(new RemoveAllDataFromCacheCommand(this)); }
Remove all data from cache. This will clear all data stored by the {@link CacheManager} of the {@link SpiceService}.
removeAllDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public void setFailOnCacheError(final boolean failOnCacheError) { executeCommand(new SetFailOnCacheErrorCommand(this, failOnCacheError)); }
Configure the behavior in case of error during reading/writing cache. <br/> Specify wether an error on reading/writing cache must fail the process. @param failOnCacheError true if an error must fail the process
setFailOnCacheError
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
private <T> void addRequestListenerToListOfRequestListeners(final CachedSpiceRequest<T> cachedSpiceRequest, final RequestListener<T> requestListener) { synchronized (mapRequestToLaunchToRequestListener) { Set<RequestListener<?>> listeners = mapRequestToLaunchToRequestListener.get(cachedSpiceRequest); if (listeners == null) { listeners = Collections.synchronizedSet(new HashSet<RequestListener<?>>()); this.mapRequestToLaunchToRequestListener.put(cachedSpiceRequest, listeners); } listeners.add(requestListener); } }
Configure the behavior in case of error during reading/writing cache. <br/> Specify wether an error on reading/writing cache must fail the process. @param failOnCacheError true if an error must fail the process
addRequestListenerToListOfRequestListeners
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
@Override public void onServiceConnected(final ComponentName name, final IBinder service) { lockAcquireService.lock(); try { if (service instanceof SpiceServiceBinder) { spiceService = ((SpiceServiceBinder) service).getSpiceService(); spiceService.addSpiceServiceListener(removerSpiceServiceListener); Ln.d("Bound to service : " + spiceService.getClass().getSimpleName()); conditionServiceBound.signalAll(); } else { Ln.e("Unexpected IBinder service at onServiceConnected :%s ", service.getClass().getName()); } } finally { lockAcquireService.unlock(); } }
Reacts to binding/unbinding with {@link SpiceService}.
onServiceConnected
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
@Override public void onRequestAdded(CachedSpiceRequest<?> cachedSpiceRequest, RequestProcessingContext requestProcessingContext) { Set<RequestListener<?>> listeners = mapRequestToLaunchToRequestListener.remove(cachedSpiceRequest); if (listeners != null) { mapPendingRequestToRequestListener.put(cachedSpiceRequest, listeners); } }
Called when a request has been processed by the {@link SpiceService}.
onRequestAdded
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
@Override public void onRequestAggregated(CachedSpiceRequest<?> cachedSpiceRequest, RequestProcessingContext requestProcessingContext) { Set<RequestListener<?>> listeners = mapPendingRequestToRequestListener.get(cachedSpiceRequest); if (listeners == null) { listeners = Collections.synchronizedSet(new HashSet<RequestListener<?>>()); mapPendingRequestToRequestListener.put(cachedSpiceRequest, listeners); } Set<RequestListener<?>> listenersToLaunch = mapRequestToLaunchToRequestListener.remove(cachedSpiceRequest); if (listenersToLaunch != null) { synchronized (mapPendingRequestToRequestListener) { listeners.addAll(listenersToLaunch); } } }
Called when a request has been processed by the {@link SpiceService}.
onRequestAggregated
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
@Override public void onRequestNotFound(CachedSpiceRequest<?> cachedSpiceRequest, RequestProcessingContext requestProcessingContext) { mapRequestToLaunchToRequestListener.remove(cachedSpiceRequest); }
Called when a request has been processed by the {@link SpiceService}.
onRequestNotFound
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
@Override public void onRequestProcessed(final CachedSpiceRequest<?> cachedSpiceRequest, RequestProcessingContext requestProcessingContext) { mapPendingRequestToRequestListener.remove(cachedSpiceRequest); }
Called when a request has been processed by the {@link SpiceService}.
onRequestProcessed
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
protected void waitForServiceToBeBound() throws InterruptedException { Ln.d("Waiting for service to be bound."); lockAcquireService.lock(); try { while (spiceService == null && (!requestQueue.isEmpty() || !isStopped)) { conditionServiceBound.await(); } Ln.d("Bound ok."); } finally { lockAcquireService.unlock(); } }
Wait for acquiring binding to {@link SpiceService}. @throws InterruptedException in case the binding is interrupted.
waitForServiceToBeBound
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
protected void waitForServiceToBeUnbound() throws InterruptedException { Ln.d("Waiting for service to be unbound."); lockAcquireService.lock(); try { while (spiceService != null) { conditionServiceUnbound.await(); } } finally { lockAcquireService.unlock(); } }
Wait for acquiring binding to {@link SpiceService}. @throws InterruptedException in case the binding is interrupted.
waitForServiceToBeUnbound
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
protected <T> Future<T> executeCommand(SpiceManagerCommand<T> spiceManagerCommand) { if (executorService == null || executorService.isShutdown()) { return null; } return executorService.submit(spiceManagerCommand); }
Wait for acquiring binding to {@link SpiceService}. @throws InterruptedException in case the binding is interrupted.
executeCommand
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
private void checkServiceIsProperlyDeclaredInAndroidManifest(final Context context) { final Intent intentCheck = new Intent(context, spiceServiceClass); if (context.getPackageManager().queryIntentServices(intentCheck, 0).isEmpty()) { shouldStop(); throw new RuntimeException("Impossible to start SpiceManager as no service of class : " + spiceServiceClass.getName() + " is registered in AndroidManifest.xml file !"); } }
Wait for acquiring binding to {@link SpiceService}. @throws InterruptedException in case the binding is interrupted.
checkServiceIsProperlyDeclaredInAndroidManifest
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
private void dumpMap(final StringBuilder stringBuilder, final Map<CachedSpiceRequest<?>, Set<RequestListener<?>>> map) { synchronized (map) { stringBuilder.append(" request count= "); stringBuilder.append(mapRequestToLaunchToRequestListener.keySet().size()); stringBuilder.append(", listeners per requests = ["); for (final Map.Entry<CachedSpiceRequest<?>, Set<RequestListener<?>>> entry : map.entrySet()) { stringBuilder.append(entry.getKey().getClass().getName()); stringBuilder.append(":"); stringBuilder.append(entry.getKey()); stringBuilder.append(" --> "); if (entry.getValue() == null) { stringBuilder.append(entry.getValue()); } else { stringBuilder.append(entry.getValue().size()); } stringBuilder.append(" listeners"); stringBuilder.append('\n'); } stringBuilder.append(']'); stringBuilder.append('\n'); } }
Wait for acquiring binding to {@link SpiceService}. @throws InterruptedException in case the binding is interrupted.
dumpMap
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
@Override public T call() { try { spiceManager.waitForServiceToBeBound(); if (spiceManager.spiceService == null) { return null; } spiceManager.lockSendRequestsToService.lock(); try { if (spiceManager.spiceService == null || spiceManager.isStopped) { return null; } T result = executeWhenBound(spiceManager.spiceService); successFull = true; return result; } catch (Exception e) { Ln.e(e); this.exception = e; return null; } finally { spiceManager.lockSendRequestsToService.unlock(); } } catch (InterruptedException e) { Ln.e(e, "Spice command %s couldn't bind to service.", getClass().getName()); return null; } }
Wait for acquiring binding to {@link SpiceService}. @throws InterruptedException in case the binding is interrupted.
call
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public boolean isSuccessFull() { return successFull; }
Wait for acquiring binding to {@link SpiceService}. @throws InterruptedException in case the binding is interrupted.
isSuccessFull
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public Exception getException() { return exception; }
Wait for acquiring binding to {@link SpiceService}. @throws InterruptedException in case the binding is interrupted.
getException
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
protected RequestProcessor createRequestProcessor(CacheManager cacheManager, RequestProgressManager requestProgressManager, RequestRunner requestRunner) { return new RequestProcessor(cacheManager, requestProgressManager, requestRunner); }
Factory method to create an entity responsible for processing requests send to the SpiceService. The default implementation of this method will return a {@link RequestProcessor}. Override this method if you want to inject a custom request processor. This feature has been implemented following a request from Christopher Jenkins. @param cacheManager the cache manager used by this service. @param requestProgressManager will notify of requests progress. @param requestRunner executes requests. @return a {@link RequestProcessor} that will be used to process requests.
createRequestProcessor
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
protected RequestProcessorListener createRequestProcessorListener() { return new SelfStopperRequestProcessorListener(); }
Creates a {@link RequestProcessorListener} for the {@link RequestProcessor} used by this service. See a typical implementation : @see {@link SelfStopperRequestProcessorListener}. @return a new instance {@link RequestProcessorListener} for the {@link RequestProcessor} used by this service.
createRequestProcessorListener
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
protected RequestProcessor getRequestProcessor() { return requestProcessor; }
For testing purposes only. @return the request processor of this spice service.
getRequestProcessor
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
protected RequestListenerNotifier createRequestRequestListenerNotifier() { return new DefaultRequestListenerNotifier(); }
Method to create a Request Progress Reporter object which is responsible for informing the listeners of the current state of each request. You can use this method to modify the existing behavior @return {@link RequestListenerNotifier}
createRequestRequestListenerNotifier
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
protected NetworkStateChecker getNetworkStateChecker() { return new DefaultNetworkStateChecker(); }
Factory method to create an entity responsible to check for network state. The default implementation of this method will return a {@link DefaultNetworkStateChecker}. Override this method if you want to inject a custom network state for testing or to adapt to connectivity changes on the Android. This method is also useful to create non-network related requests. In that case create a {@link NetworkStateChecker} that always return true. This feature has been implemented following a request from Pierre Durand. @return a {@link NetworkStateChecker} that will be used to determine if network state allows requests executions.
getNetworkStateChecker
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
protected ExecutorService getExecutorService() { final int coreThreadCount = getCoreThreadCount(); final int maxThreadCount = getMaximumThreadCount(); final int threadPriority = getThreadPriority(); if (coreThreadCount <= 0 || maxThreadCount <= 0) { throw new IllegalArgumentException("Thread count must be >= 1"); } else { PriorityThreadPoolExecutor executor = PriorityThreadPoolExecutor .getPriorityExecutor(coreThreadCount, maxThreadCount, threadPriority); executor.setKeepAliveTime(getKeepAliveTime(), TimeUnit.NANOSECONDS); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { executor.allowCoreThreadTimeOut(getKeepAliveTime() != 0 && isCoreThreadDisposable()); } return executor; } }
Factory method to create an {@link ExecutorService} that will be used to execute requests. The default implementation of this method will create a single threaded or multi-threaded {@link ExecutorService} depending on the number of threads returned by {@link #getThreadCount()} and will assign them the priority returned by {@link #getThreadPriority()}. <p/> If you override this method in your service, you can supply a custom {@link ExecutorService}. <p/> This feature has been implemented following a request from Riccardo Ciovati. @return the {@link ExecutorService} to be used to execute requests .
getExecutorService
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
protected SpiceServiceListenerNotifier createSpiceServiceListenerNotifier() { return new SpiceServiceListenerNotifier(); }
Creates the SpiceServiceListenerNotifier. @return {@link SpiceServiceListenerNotifier}
createSpiceServiceListenerNotifier
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
@SuppressWarnings("deprecation") public Notification createDefaultNotification() { Notification notification = null; if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { notification = new Notification.Builder(this).setSmallIcon(getApplicationInfo().icon).build(); } else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { notification = new Notification.Builder(this).setSmallIcon(getApplicationInfo().icon).getNotification(); } else { notification = new Notification(); notification.icon = getApplicationInfo().icon; // temporary fix https://github.com/octo-online/robospice/issues/200 PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0); notification.setLatestEventInfo(this, "", "", pendingIntent); notification.tickerText = null; notification.when = System.currentTimeMillis(); } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { notification.priority = Notification.PRIORITY_MIN; } return notification; }
This method can be overriden in order to create a foreground SpiceService. By default, it will create a notification that can be used to set a spiceService to foreground (depending on the versions of Android, the behavior is different : before ICS, no notification is shown, on ICS+, a notification is shown with app icon). On Jelly Bean+, the notifiation only appears when notification bar is expanded / pulled down. @return a notification used to tell user that the SpiceService is still running and processing requests.
createDefaultNotification
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
protected int getNotificationId() { return DEFAULT_NOTIFICATION_ID; }
This method can be overriden in order to create a foreground SpiceService. By default, it will create a notification that can be used to set a spiceService to foreground (depending on the versions of Android, the behavior is different : before ICS, no notification is shown, on ICS+, a notification is shown with app icon). On Jelly Bean+, the notifiation only appears when notification bar is expanded / pulled down. @return a notification used to tell user that the SpiceService is still running and processing requests.
getNotificationId
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
@Override public void onDestroy() { requestProcessor.shouldStop(); Ln.d("SpiceService instance destroyed."); super.onDestroy(); }
This method can be overriden in order to create a foreground SpiceService. By default, it will create a notification that can be used to set a spiceService to foreground (depending on the versions of Android, the behavior is different : before ICS, no notification is shown, on ICS+, a notification is shown with app icon). On Jelly Bean+, the notifiation only appears when notification bar is expanded / pulled down. @return a notification used to tell user that the SpiceService is still running and processing requests.
onDestroy
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public int getThreadCount() { return DEFAULT_THREAD_COUNT; }
Override this method to increase the number of threads used to process requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests. Defaults to {@link #DEFAULT_THREAD_COUNT}.
getThreadCount
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public int getCoreThreadCount() { return getThreadCount(); }
Override this method to increase the number of core threads used to process requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests. Defaults to {@link #DEFAULT_THREAD_COUNT}.
getCoreThreadCount
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public int getMaximumThreadCount() { return getThreadCount(); }
Override this method to increase the number of maximum threads used to process requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests. Defaults to {@link #DEFAULT_THREAD_COUNT}.
getMaximumThreadCount
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public int getKeepAliveTime() { return DEFAULT_THREAD_KEEP_ALIVE_TIME; }
Override this method to set the keep alive time for core threads {@link #getExecutorService()}. @return the time to keep alive idle threads on {@see TimeUnit.NANOSECONDS}. Defaults to {@link #DEFAULT_THREAD_KEEP_ALIVE_TIME}.
getKeepAliveTime
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public boolean isCoreThreadDisposable() { return true; }
Override this method to disable timeout on core threads. This is only taken into consideration for Android SDK 9+. {@link #getExecutorService()}. @return whether core threads are disposable or not (DEFAULT=true).
isCoreThreadDisposable
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public int getThreadPriority() { return DEFAULT_THREAD_PRIORITY; }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
getThreadPriority
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public void addRequest(final CachedSpiceRequest<?> request, final Set<RequestListener<?>> listRequestListener) { currentPendingRequestCount++; requestProcessor.addRequest(request, listRequestListener); showNotificationIfNotBoundAndHasPendingRequestsOtherwiseHideNotification(); }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
addRequest
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public boolean removeDataFromCache(final Class<?> clazz, final Object cacheKey) { return requestProcessor.removeDataFromCache(clazz, cacheKey); }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
removeDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public <T> List<Object> getAllCacheKeys(final Class<T> clazz) { return cacheManager.getAllCacheKeys(clazz); }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
getAllCacheKeys
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public <T> List<T> loadAllDataFromCache(final Class<T> clazz) throws CacheLoadingException, CacheCreationException { return cacheManager.loadAllDataFromCache(clazz); }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
loadAllDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public <T> T getDataFromCache(final Class<T> clazz, final Object cacheKey) throws CacheLoadingException, CacheCreationException { return cacheManager.loadDataFromCache(clazz, cacheKey, DurationInMillis.ALWAYS_RETURNED); }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
getDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public <T> T putDataInCache(final Object cacheKey, T data) throws CacheSavingException, CacheCreationException { return cacheManager.saveDataToCacheAndReturnData(data, cacheKey); }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
putDataInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public boolean isDataInCache(Class<?> clazz, Object cacheKey, long cacheExpiryDuration) throws CacheCreationException { return cacheManager.isDataInCache(clazz, cacheKey, cacheExpiryDuration); }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
isDataInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public Date getDateOfDataInCache(Class<?> clazz, Object cacheKey) throws CacheLoadingException, CacheCreationException { return cacheManager.getDateOfDataInCache(clazz, cacheKey); }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
getDateOfDataInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public boolean isFailOnCacheError() { return requestProcessor.isFailOnCacheError(); }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
isFailOnCacheError
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public void dontNotifyRequestListenersForRequest(final CachedSpiceRequest<?> request, final Collection<RequestListener<?>> listRequestListener) { requestProcessor.dontNotifyRequestListenersForRequest(request, listRequestListener); }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
dontNotifyRequestListenersForRequest
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
@Override public IBinder onBind(final Intent intent) { isBound = true; showNotificationIfNotBoundAndHasPendingRequestsOtherwiseHideNotification(); return mSpiceServiceBinder; }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
onBind
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
@Override public void onRebind(Intent intent) { isBound = true; showNotificationIfNotBoundAndHasPendingRequestsOtherwiseHideNotification(); super.onRebind(intent); }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
onRebind
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
@Override public boolean onUnbind(final Intent intent) { isBound = false; showNotificationIfNotBoundAndHasPendingRequestsOtherwiseHideNotification(); stopIfNotBoundAndHasNoPendingRequests(); return true; }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
onUnbind
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
@Override public void requestsInProgress() { }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
requestsInProgress
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
@Override public void allRequestComplete() { currentPendingRequestCount = 0; stopIfNotBoundAndHasNoPendingRequests(); }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
allRequestComplete
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public SpiceService getSpiceService() { return spiceService; }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
getSpiceService
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
private void stopIfNotBoundAndHasNoPendingRequests() { Ln.v("Pending requests : " + currentPendingRequestCount); if (currentPendingRequestCount == 0 && !isBound) { stopSelf(); } }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
stopIfNotBoundAndHasNoPendingRequests
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
private void showNotificationIfNotBoundAndHasPendingRequestsOtherwiseHideNotification() { // http://stackoverflow.com/a/13359680/693752 if (notification == null || isJUnit) { return; } Ln.v("Pending requests : " + currentPendingRequestCount); if (isBound || currentPendingRequestCount == 0) { Ln.v("Stop foreground"); stopForeground(true); } else { Ln.v("Start foreground"); startForeground(notification); } }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
showNotificationIfNotBoundAndHasPendingRequestsOtherwiseHideNotification
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
private void startForeground(final Notification notification) { try { final Method setForegroundMethod = Service.class.getMethod("startForeground", int.class, Notification.class); setForegroundMethod.invoke(this, getNotificationId(), notification); } catch (final SecurityException e) { Ln.e(e, "Unable to start a service in foreground"); } catch (final NoSuchMethodException e) { Ln.e(e, "Unable to start a service in foreground"); } catch (final IllegalArgumentException e) { Ln.e(e, "Unable to start a service in foreground"); } catch (final IllegalAccessException e) { Ln.e(e, "Unable to start a service in foreground"); } catch (final InvocationTargetException e) { Ln.e(e, "Unable to start a service in foreground"); } }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
startForeground
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public static final void setIsJunit(boolean b) { isJUnit = b; }
Override this method to change the priority of threads requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests.Defaults to {@link #DEFAULT_THREAD_PRIORITY}.
setIsJunit
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
@Override public CacheManager createCacheManager(Application application) { // Just return an empty CacheManager return new CacheManager() { @Override public <T> T saveDataToCacheAndReturnData(T data, Object cacheKey) throws CacheSavingException, CacheCreationException { return data; } }; }
Concrete implementation of {@link SpiceService} with an empty CacheManager. Using this class, requests will not be cached. @author rciovati
createCacheManager
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/UncachedSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/UncachedSpiceService.java
Apache-2.0
@Override public <T> T saveDataToCacheAndReturnData(T data, Object cacheKey) throws CacheSavingException, CacheCreationException { return data; }
Concrete implementation of {@link SpiceService} with an empty CacheManager. Using this class, requests will not be cached. @author rciovati
saveDataToCacheAndReturnData
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/UncachedSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/UncachedSpiceService.java
Apache-2.0
@Override public boolean isNetworkAvailable(final Context context) { final ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo[] allNetworkInfos = connectivityManager.getAllNetworkInfo(); for (final NetworkInfo networkInfo : allNetworkInfos) { if (networkInfo.getState() == NetworkInfo.State.CONNECTED || networkInfo.getState() == NetworkInfo.State.CONNECTING) { return true; } } return false; }
Consider network to be available when one network connection is up, whatever it is. This class will also ensure that both <tt>android.permission.ACCESS_NETWORK_STATE</tt> and <tt>android.permission.ACCESS_NETWORK</tt> are granted. @author sni
isNetworkAvailable
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/networkstate/DefaultNetworkStateChecker.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/networkstate/DefaultNetworkStateChecker.java
Apache-2.0
@Override public void checkPermissions(final Context context) { checkHasPermission(context, Manifest.permission.ACCESS_NETWORK_STATE); checkHasPermission(context, Manifest.permission.INTERNET); }
Consider network to be available when one network connection is up, whatever it is. This class will also ensure that both <tt>android.permission.ACCESS_NETWORK_STATE</tt> and <tt>android.permission.ACCESS_NETWORK</tt> are granted. @author sni
checkPermissions
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/networkstate/DefaultNetworkStateChecker.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/networkstate/DefaultNetworkStateChecker.java
Apache-2.0
private boolean checkHasPermission(final Context context, final String permissionName) { final boolean hasPermission = context.getPackageManager().checkPermission(permissionName, context.getPackageName()) == PackageManager.PERMISSION_GRANTED; if (!hasPermission) { throw new SecurityException("Application doesn\'t declare <uses-permission android:name=\"" + permissionName + "\" />"); } return true; }
Consider network to be available when one network connection is up, whatever it is. This class will also ensure that both <tt>android.permission.ACCESS_NETWORK_STATE</tt> and <tt>android.permission.ACCESS_NETWORK</tt> are granted. @author sni
checkHasPermission
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/networkstate/DefaultNetworkStateChecker.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/networkstate/DefaultNetworkStateChecker.java
Apache-2.0
public static Intent createIntent(final Context context, final Class<? extends SpiceNotificationService> clazz, final Class<? extends SpiceService> spiceServiceClass, final int notificationId, final Class<?> requestResultType, final String cacheKey, final boolean foreground) { final Intent intent = new Intent(context, clazz); intent.putExtra(BUNDLE_KEY_NOTIFICATION_ID, notificationId); intent.putExtra(BUNDLE_KEY_SERVICE_CLASS, spiceServiceClass); intent.putExtra(BUNDLE_KEY_REQUEST_CLASS, requestResultType); intent.putExtra(BUNDLE_KEY_REQUEST_CACHE_KEY, cacheKey); intent.putExtra(BUNDLE_KEY_FOREGROUND, foreground); return intent; }
Will create notifications to display the progress of a given request. This class is a base class to create such a service. Implementations will only focus on creating notifications to "follow" the status of given request. All informations about the request to track are provided to the service via an Intent. This services will be automatically stopped when the requests has been fully processed. @author SNI
createIntent
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
Apache-2.0
@Override public IBinder onBind(final Intent intent) { return null; }
Will create notifications to display the progress of a given request. This class is a base class to create such a service. Implementations will only focus on creating notifications to "follow" the status of given request. All informations about the request to track are provided to the service via an Intent. This services will be automatically stopped when the requests has been fully processed. @author SNI
onBind
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
Apache-2.0
@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" }) @Override public final void onStart(final Intent intent, final int startId) { super.onStart(intent, startId); notificationId = intent.getIntExtra(BUNDLE_KEY_NOTIFICATION_ID, DEFAULT_ROBOSPICE_NOTIFICATION_ID); requestClass = (Class<?>) intent.getSerializableExtra(BUNDLE_KEY_REQUEST_CLASS); requestCacheKey = intent.getStringExtra(BUNDLE_KEY_REQUEST_CACHE_KEY); spiceServiceClass = (Class<? extends SpiceService>) intent.getSerializableExtra(BUNDLE_KEY_SERVICE_CLASS); if (spiceServiceClass == null) { throw new RuntimeException("Please specify a service class to monitor. Use #createIntent as helper."); } foreground = intent.getBooleanExtra(BUNDLE_KEY_FOREGROUND, true); spiceManager = new SpiceManager(spiceServiceClass); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); spiceManager.start(this); spiceManager.addListenerIfPending(requestClass, requestCacheKey, new NotificationRequestListener()); if (foreground) { startForeground(notificationId, onCreateForegroundNotification()); } }
Will create notifications to display the progress of a given request. This class is a base class to create such a service. Implementations will only focus on creating notifications to "follow" the status of given request. All informations about the request to track are provided to the service via an Intent. This services will be automatically stopped when the requests has been fully processed. @author SNI
onStart
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
Apache-2.0
@Override public final void onDestroy() { spiceManager.shouldStop(); super.onDestroy(); }
Will create notifications to display the progress of a given request. This class is a base class to create such a service. Implementations will only focus on creating notifications to "follow" the status of given request. All informations about the request to track are provided to the service via an Intent. This services will be automatically stopped when the requests has been fully processed. @author SNI
onDestroy
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
Apache-2.0
public Notification onCreateForegroundNotification() { throw new RuntimeException("If you use foreground = true, then you must override onCreateForegroundNotification()."); }
Will create notifications to display the progress of a given request. This class is a base class to create such a service. Implementations will only focus on creating notifications to "follow" the status of given request. All informations about the request to track are provided to the service via an Intent. This services will be automatically stopped when the requests has been fully processed. @author SNI
onCreateForegroundNotification
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
Apache-2.0
@Override public void onRequestFailure(final SpiceException arg0) { final Notification notification = onCreateNotificationForRequestFailure(arg0); notificationManager.notify(notificationId, notification); stopSelf(); }
Will create notifications to display the progress of a given request. This class is a base class to create such a service. Implementations will only focus on creating notifications to "follow" the status of given request. All informations about the request to track are provided to the service via an Intent. This services will be automatically stopped when the requests has been fully processed. @author SNI
onRequestFailure
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
Apache-2.0
@Override public void onRequestSuccess(final T result) { final Notification notification = onCreateNotificationForRequestSuccess(); notificationManager.notify(notificationId, notification); stopSelf(); }
Will create notifications to display the progress of a given request. This class is a base class to create such a service. Implementations will only focus on creating notifications to "follow" the status of given request. All informations about the request to track are provided to the service via an Intent. This services will be automatically stopped when the requests has been fully processed. @author SNI
onRequestSuccess
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
Apache-2.0
@Override public void onRequestProgressUpdate(final RequestProgress progress) { final Notification notification = onCreateNotificationForRequestProgress(progress); notificationManager.notify(notificationId, notification); if (progress.getStatus() == RequestStatus.COMPLETE) { stopSelf(); } }
Will create notifications to display the progress of a given request. This class is a base class to create such a service. Implementations will only focus on creating notifications to "follow" the status of given request. All informations about the request to track are provided to the service via an Intent. This services will be automatically stopped when the requests has been fully processed. @author SNI
onRequestProgressUpdate
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceNotificationService.java
Apache-2.0
public static Intent createIntent(final Context context, final Class<? extends SpiceServiceListenerNotificationService> clazz, final Class<? extends SpiceService> spiceServiceClass, final int notificationId, final boolean foreground) { final Intent intent = new Intent(context, clazz); intent.putExtra(BUNDLE_KEY_NOTIFICATION_ID, notificationId); intent.putExtra(BUNDLE_KEY_SERVICE_CLASS, spiceServiceClass); intent.putExtra(BUNDLE_KEY_FOREGROUND, foreground); return intent; }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
createIntent
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
@Override public IBinder onBind(final Intent intent) { return null; }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
onBind
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
public Class<? extends SpiceService> getSpiceServiceClass() { return spiceServiceClass; }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
getSpiceServiceClass
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
@SuppressWarnings({ "unchecked", "deprecation" }) @Override public final void onStart(final Intent intent, final int startId) { super.onStart(intent, startId); if (intent == null) { return; } notificationId = intent.getIntExtra(BUNDLE_KEY_NOTIFICATION_ID, DEFAULT_ROBOSPICE_NOTIFICATION_ID); spiceServiceClass = (Class<? extends SpiceService>) intent.getSerializableExtra(BUNDLE_KEY_SERVICE_CLASS); if (spiceServiceClass == null) { throw new RuntimeException("Please specify a service class to monitor. Use #createIntent as helper."); } foreground = intent.getBooleanExtra(BUNDLE_KEY_FOREGROUND, true); spiceManager = new SpiceManager(spiceServiceClass); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); spiceManager.start(this); spiceManager.addSpiceServiceListener(new NotificationSpiceServiceListener()); if (foreground) { startForeground(notificationId, onCreateForegroundNotification()); } Ln.d(getClass().getSimpleName() + " started."); }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
onStart
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
@Override public final void onDestroy() { spiceManager.shouldStop(); super.onDestroy(); }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
onDestroy
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
public Notification onCreateForegroundNotification() { throw new RuntimeException("If you use foreground = true, then you must override onCreateForegroundNotification()."); }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
onCreateForegroundNotification
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
public int getId() { return id; }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
getId
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
public Notification getNotification() { return notification; }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
getNotification
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
@Override public void onRequestSucceeded(CachedSpiceRequest<?> request, RequestProcessingContext requestProcessingContext) { final SpiceNotification notification = onCreateNotificationForRequestSucceeded(request, requestProcessingContext); notificationManager.notify(notification.getId(), notification.getNotification()); }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
onRequestSucceeded
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
@Override public void onRequestFailed(CachedSpiceRequest<?> request, RequestProcessingContext requestProcessingContext) { final SpiceNotification notification = onCreateNotificationForRequestFailed(request, requestProcessingContext); notificationManager.notify(notification.getId(), notification.getNotification()); }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
onRequestFailed
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
@Override public void onRequestCancelled(CachedSpiceRequest<?> request, RequestProcessingContext requestProcessingContext) { final SpiceNotification notification = onCreateNotificationForRequestCancelled(request, requestProcessingContext); notificationManager.notify(notification.getId(), notification.getNotification()); }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
onRequestCancelled
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
@Override public void onRequestProgressUpdated(CachedSpiceRequest<?> request, RequestProcessingContext requestProcessingContext) { final SpiceNotification notification = onCreateNotificationForRequestProgressUpdate(request, requestProcessingContext); notificationManager.notify(notification.getId(), notification.getNotification()); }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
onRequestProgressUpdated
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
@Override public void onRequestAdded(CachedSpiceRequest<?> request, RequestProcessingContext requestProcessingContext) { final SpiceNotification notification = onCreateNotificationForRequestAdded(request, requestProcessingContext); notificationManager.notify(notification.getId(), notification.getNotification()); }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
onRequestAdded
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
@Override public void onRequestAggregated(CachedSpiceRequest<?> request, RequestProcessingContext requestProcessingContext) { final SpiceNotification notification = onCreateNotificationForRequestAdded(request, requestProcessingContext); notificationManager.notify(notification.getId(), notification.getNotification()); }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
onRequestAggregated
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
@Override public void onRequestNotFound(CachedSpiceRequest<?> request, RequestProcessingContext requestProcessingContext) { final SpiceNotification notification = onCreateNotificationForRequestNotFound(request, requestProcessingContext); notificationManager.notify(notification.getId(), notification.getNotification()); }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
onRequestNotFound
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
@Override public void onRequestProcessed(CachedSpiceRequest<?> cachedSpiceRequest, RequestProcessingContext requestProcessingContext) { final SpiceNotification notification = onCreateNotificationForRequestProcessed(cachedSpiceRequest, requestProcessingContext); notificationManager.notify(notification.getId(), notification.getNotification()); }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
onRequestProcessed
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
@Override public void onServiceStopped() { final SpiceNotification notification = onCreateNotificationForServiceStopped(); notificationManager.notify(notification.getId(), notification.getNotification()); stopSelf(); }
Will display updates in the status of a given spice service itself by displaying notifications when the service processes a request, updates its progress, etc. This service will need to be started via an intent and will be stopped automatically when the target spice service stops. @author SNI
onServiceStopped
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/notification/SpiceServiceListenerNotificationService.java
Apache-2.0
@Override public Thread newThread(Runnable runnable) { Thread thread = new Thread(runnable); thread.setPriority(threadPriority); return thread; }
Creates threads with a low priority. @author SNI
newThread
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/priority/CustomizablePriorityThreadFactory.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/priority/CustomizablePriorityThreadFactory.java
Apache-2.0
@Override public T poll() { pauseLock.lock(); try { while (isPaused) { unpaused.await(); } } catch (InterruptedException ie) { throw new RuntimeException("Interrupted while paused."); } finally { pauseLock.unlock(); } return super.poll(); }
This class is used internally. It makes testing easier. The queue will not allow to {@link #poll()} or {@link #take()} an element when paused. @author SNI
poll
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/priority/PausablePriorityBlockingQueue.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/priority/PausablePriorityBlockingQueue.java
Apache-2.0
@Override public T poll(long timeout, TimeUnit unit) throws InterruptedException { pauseLock.lock(); try { while (isPaused) { unpaused.await(); } } catch (InterruptedException ie) { throw new RuntimeException("Interrupted while paused."); } finally { pauseLock.unlock(); } return super.poll(timeout, unit); }
This class is used internally. It makes testing easier. The queue will not allow to {@link #poll()} or {@link #take()} an element when paused. @author SNI
poll
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/priority/PausablePriorityBlockingQueue.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/priority/PausablePriorityBlockingQueue.java
Apache-2.0