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 onRequestProgressUpdated(CachedSpiceRequest<?> request, RequestProcessingContext requestProcessingContext) { }
Defines the behavior of a listener that will be notified of request processing by the {@link SpiceService}. @author sni
onRequestProgressUpdated
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceAdapter.java
Apache-2.0
@Override public void onRequestAdded(CachedSpiceRequest<?> request, RequestProcessingContext requestProcessingContext) { }
Defines the behavior of a listener that will be notified of request processing by the {@link SpiceService}. @author sni
onRequestAdded
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceAdapter.java
Apache-2.0
@Override public void onRequestAggregated(CachedSpiceRequest<?> request, RequestProcessingContext requestProcessingContext) { }
Defines the behavior of a listener that will be notified of request processing by the {@link SpiceService}. @author sni
onRequestAggregated
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceAdapter.java
Apache-2.0
@Override public void onRequestNotFound(CachedSpiceRequest<?> request, RequestProcessingContext requestProcessingContext) { }
Defines the behavior of a listener that will be notified of request processing by the {@link SpiceService}. @author sni
onRequestNotFound
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceAdapter.java
Apache-2.0
@Override public void onRequestProcessed(CachedSpiceRequest<?> cachedSpiceRequest, RequestProcessingContext requestProcessingContext) { }
Defines the behavior of a listener that will be notified of request processing by the {@link SpiceService}. @author sni
onRequestProcessed
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceAdapter.java
Apache-2.0
@Override public void onServiceStopped() { }
Defines the behavior of a listener that will be notified of request processing by the {@link SpiceService}. @author sni
onServiceStopped
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceAdapter.java
Apache-2.0
public void setExecutionThread(Thread executionThread) { this.executionThread = executionThread; }
Defines the behavior of a listener that will be notified of request processing by the {@link SpiceService}. @author sni
setExecutionThread
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceListener.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceListener.java
Apache-2.0
public Thread getExecutionThread() { return executionThread; }
Defines the behavior of a listener that will be notified of request processing by the {@link SpiceService}. @author sni
getExecutionThread
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceListener.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceListener.java
Apache-2.0
public void setRequestProgress(RequestProgress requestProgress) { this.requestProgress = requestProgress; }
Defines the behavior of a listener that will be notified of request processing by the {@link SpiceService}. @author sni
setRequestProgress
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceListener.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceListener.java
Apache-2.0
public RequestProgress getRequestProgress() { return requestProgress; }
Defines the behavior of a listener that will be notified of request processing by the {@link SpiceService}. @author sni
getRequestProgress
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceListener.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceListener.java
Apache-2.0
public void setRequestListeners(Set<RequestListener<?>> requestListeners) { this.requestListeners = requestListeners; }
Defines the behavior of a listener that will be notified of request processing by the {@link SpiceService}. @author sni
setRequestListeners
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceListener.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceListener.java
Apache-2.0
public Set<RequestListener<?>> getRequestListeners() { return requestListeners; }
Defines the behavior of a listener that will be notified of request processing by the {@link SpiceService}. @author sni
getRequestListeners
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceListener.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/listener/SpiceServiceListener.java
Apache-2.0
private void post(final Runnable r, final Object token) { handlerResponse.postAtTime(r, token, SystemClock.uptimeMillis()); }
Default implementation of RequestListenerNotifier. It will notify listeners on the ui thread. @author Andrew Clark
post
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
Apache-2.0
@Override public <T> void notifyListenersOfRequestNotFound(final CachedSpiceRequest<T> request, final Set<RequestListener<?>> listRequestListener) { post(new NotFoundRunnable(listRequestListener), request.getRequestCacheKey()); }
Default implementation of RequestListenerNotifier. It will notify listeners on the ui thread. @author Andrew Clark
notifyListenersOfRequestNotFound
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
Apache-2.0
@Override public <T> void notifyListenersOfRequestAdded(final CachedSpiceRequest<T> request, Set<RequestListener<?>> listeners) { // does nothing for now }
Default implementation of RequestListenerNotifier. It will notify listeners on the ui thread. @author Andrew Clark
notifyListenersOfRequestAdded
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
Apache-2.0
@Override public <T> void notifyListenersOfRequestAggregated(final CachedSpiceRequest<T> request, Set<RequestListener<?>> listeners) { // does nothing for now }
Default implementation of RequestListenerNotifier. It will notify listeners on the ui thread. @author Andrew Clark
notifyListenersOfRequestAggregated
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
Apache-2.0
@Override public <T> void notifyListenersOfRequestProgress(final CachedSpiceRequest<T> request, final Set<RequestListener<?>> listeners, final RequestProgress progress) { post(new ProgressRunnable(listeners, progress), request.getRequestCacheKey()); }
Default implementation of RequestListenerNotifier. It will notify listeners on the ui thread. @author Andrew Clark
notifyListenersOfRequestProgress
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
Apache-2.0
@Override public <T> void notifyListenersOfRequestSuccess(final CachedSpiceRequest<T> request, final T result, final Set<RequestListener<?>> listeners) { post(new ResultRunnable<T>(listeners, result), request.getRequestCacheKey()); }
Default implementation of RequestListenerNotifier. It will notify listeners on the ui thread. @author Andrew Clark
notifyListenersOfRequestSuccess
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
Apache-2.0
@Override public <T> void notifyListenersOfRequestFailure(final CachedSpiceRequest<T> request, final SpiceException e, final Set<RequestListener<?>> listeners) { post(new ResultRunnable<T>(listeners, e), request.getRequestCacheKey()); }
Default implementation of RequestListenerNotifier. It will notify listeners on the ui thread. @author Andrew Clark
notifyListenersOfRequestFailure
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
Apache-2.0
@Override public <T> void notifyListenersOfRequestCancellation(final CachedSpiceRequest<T> request, final Set<RequestListener<?>> listeners) { post(new ResultRunnable<T>(listeners, new RequestCancelledException("Request has been cancelled explicitely.")), request.getRequestCacheKey()); }
Default implementation of RequestListenerNotifier. It will notify listeners on the ui thread. @author Andrew Clark
notifyListenersOfRequestCancellation
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
Apache-2.0
@Override public <T> void clearNotificationsForRequest(final CachedSpiceRequest<T> request, final Set<RequestListener<?>> listeners) { handlerResponse.removeCallbacksAndMessages(request.getRequestCacheKey()); }
Default implementation of RequestListenerNotifier. It will notify listeners on the ui thread. @author Andrew Clark
clearNotificationsForRequest
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
Apache-2.0
@Override public void run() { if (listeners == null) { return; } Ln.v("Notifying " + listeners.size() + " listeners of request not found"); synchronized (listeners) { for (final RequestListener<?> listener : listeners) { if (listener != null && listener instanceof PendingRequestListener) { Ln.v("Notifying %s", listener.getClass().getSimpleName()); ((PendingRequestListener<?>) listener).onRequestNotFound(); } } } }
Default implementation of RequestListenerNotifier. It will notify listeners on the ui thread. @author Andrew Clark
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
Apache-2.0
@Override public void run() { if (listeners == null) { return; } Ln.v("Notifying " + listeners.size() + " listeners of progress " + progress); synchronized (listeners) { for (final RequestListener<?> listener : listeners) { if (listener != null && listener instanceof RequestProgressListener) { Ln.v("Notifying %s", listener.getClass().getSimpleName()); ((RequestProgressListener) listener).onRequestProgressUpdate(progress); } } } }
Default implementation of RequestListenerNotifier. It will notify listeners on the ui thread. @author Andrew Clark
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
Apache-2.0
@Override public void run() { if (listeners == null) { return; } final String resultMsg = spiceException == null ? "success" : "failure"; Ln.v("Notifying " + listeners.size() + " listeners of request " + resultMsg); synchronized (listeners) { for (final RequestListener<?> listener : listeners) { if (listener != null) { @SuppressWarnings("unchecked") final RequestListener<T> listenerOfT = (RequestListener<T>) listener; Ln.v("Notifying %s", listener.getClass().getSimpleName()); if (spiceException == null) { listenerOfT.onRequestSuccess(result); } else { listener.onRequestFailure(spiceException); } } } } }
Default implementation of RequestListenerNotifier. It will notify listeners on the ui thread. @author Andrew Clark
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/DefaultRequestListenerNotifier.java
Apache-2.0
public void addSpiceServiceListener(SpiceServiceListener spiceServiceListener) { spiceServiceListenerList.add(spiceServiceListener); if (messageQueue == null) { Ln.d("Message Queue starting"); messageQueue = new Handler(Looper.getMainLooper()); } }
The Observer Manager manages observers and passes on request events to the interested observers. @author Andrew.Clark
addSpiceServiceListener
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
int getRequestToObserverMapCount() { return spiceServiceListenerList.size(); }
The Observer Manager manages observers and passes on request events to the interested observers. @author Andrew.Clark
getRequestToObserverMapCount
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
protected void createMessageQueue() { messageQueue = new Handler(Looper.getMainLooper()); }
The Observer Manager manages observers and passes on request events to the interested observers. @author Andrew.Clark
createMessageQueue
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public void notifyObserversOfRequestNotFound(CachedSpiceRequest<?> request) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); post(new RequestNotFoundNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Inform the observers of a request. The observers can optionally observe the new request if required. @param request the request that couldn't be aggregated to another request.
notifyObserversOfRequestNotFound
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public void notifyObserversOfRequestAdded(CachedSpiceRequest<?> request, Set<RequestListener<?>> requestListeners) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); requestProcessingContext.setRequestListeners(requestListeners); post(new RequestAddedNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Inform the observers of a request. The observers can optionally observe the new request if required. @param request the request that has been added to processing queue.
notifyObserversOfRequestAdded
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public void notifyObserversOfRequestAggregated(CachedSpiceRequest<?> request, Set<RequestListener<?>> requestListeners) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); requestProcessingContext.setRequestListeners(requestListeners); post(new RequestAggregatedNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Inform the observers of a request. The observers can optionally observe the new request if required. @param request the request that has been aggregated.
notifyObserversOfRequestAggregated
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public void notifyObserversOfRequestFailure(CachedSpiceRequest<?> request) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); post(new RequestFailedNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Notify interested observers that the request failed. @param request the request that failed.
notifyObserversOfRequestFailure
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public <T> void notifyObserversOfRequestSuccess(CachedSpiceRequest<T> request) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); post(new RequestSucceededNotifier<T>(request, spiceServiceListenerList, requestProcessingContext)); }
Notify interested observers that the request succeeded. @param request the request that succeeded.
notifyObserversOfRequestSuccess
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public void notifyObserversOfRequestCancellation(CachedSpiceRequest<?> request) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); post(new RequestCancelledNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Notify interested observers that the request was cancelled. @param request the request that was cancelled.
notifyObserversOfRequestCancellation
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public void notifyObserversOfRequestProgress(CachedSpiceRequest<?> request, RequestProgress requestProgress) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); requestProcessingContext.setRequestProgress(requestProgress); post(new RequestProgressNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Notify interested observers of request progress. @param request the request in progress. @param requestProgress the progress of the request.
notifyObserversOfRequestProgress
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public void notifyObserversOfRequestProcessed(CachedSpiceRequest<?> request, Set<RequestListener<?>> requestListeners) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); requestProcessingContext.setRequestListeners(requestListeners); post(new RequestProcessedNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Notify interested observers of request completion. @param request the request that has completed. @param requestListeners the listeners to notify.
notifyObserversOfRequestProcessed
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
protected void post(Runnable runnable) { Ln.d("Message queue is " + messageQueue); if (messageQueue == null) { return; } messageQueue.postAtTime(runnable, SystemClock.uptimeMillis()); }
Add the request update to the observer message queue. @param runnable a runnable to be posted immediatly on the queue.
post
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { Ln.d("Processing request added: %s", request); synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestAdded(request, requestProcessingContext); } } }
Runnable to inform interested observers of request added @author Andrew.Clark
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { Ln.d("Processing request added: %s", request); synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestAggregated(request, requestProcessingContext); } } }
Runnable to inform interested observers of request added @author Andrew.Clark
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { Ln.d("Processing request not found: %s", request); synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestNotFound(request, requestProcessingContext); } } }
Runnable to inform interested observers of request not found @author Andrew.Clark
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestFailed(request, requestProcessingContext); } } }
Runnable to inform interested observers of request failed @author Andrew.Clark
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestSucceeded(request, requestProcessingContext); } } }
Runnable to inform interested observers of request completed @author Andrew.Clark @param <T>
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { Ln.d("Processing request cancelled: %s", request); synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestCancelled(request, requestProcessingContext); } } }
Runnable to inform interested observers of request cancelled @author Andrew.Clark
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestProgressUpdated(request, requestProcessingContext); } } }
Runnable to inform interested observers of request progress @author Andrew.Clark
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestProcessed(request, requestProcessingContext); } } }
Runnable to inform interested observers of request processing end. @author SNI
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public InputStream processStream(final int contentLength, final InputStream inputStream) throws IOException { OutputStream fileOutputStream = null; try { // touch boolean isTouchedNow = cacheFile.setLastModified(System.currentTimeMillis()); if (!isTouchedNow) { Ln.d("Modification time of file %s could not be changed normally ", cacheFile.getAbsolutePath()); } fileOutputStream = new FileOutputStream(cacheFile); readBytes(inputStream, new ProgressByteProcessor(this, fileOutputStream, contentLength)); return new FileInputStream(cacheFile); } finally { IOUtils.closeQuietly(fileOutputStream); } }
Creates a BigBinaryRequest using its own cache file to prevent any downloaded data to be stored in memory. All file received from the network (via a simple http GET request) will be stored directly in the cache file to prevent memory loss. @param url the url to get the image data from. @param cacheFile a file used to store image data. Developers will have to handle the cache file erasure by themselves. <b>This cache file is not handled by RS caching mechanism in the "normal way". </b>
processStream
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BigBinaryRequest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BigBinaryRequest.java
Apache-2.0
public File getCacheFile() { return cacheFile; }
Creates a BigBinaryRequest using its own cache file to prevent any downloaded data to be stored in memory. All file received from the network (via a simple http GET request) will be stored directly in the cache file to prevent memory loss. @param url the url to get the image data from. @param cacheFile a file used to store image data. Developers will have to handle the cache file erasure by themselves. <b>This cache file is not handled by RS caching mechanism in the "normal way". </b>
getCacheFile
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BigBinaryRequest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BigBinaryRequest.java
Apache-2.0
@Override public final InputStream loadDataFromNetwork() throws Exception { try { final HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(url).openConnection(); return processStream(httpURLConnection.getContentLength(), httpURLConnection.getInputStream()); } catch (final MalformedURLException e) { Ln.e(e, "Unable to create URL"); throw e; } catch (final IOException e) { Ln.e(e, "Unable to download binary"); throw e; } }
Abstract class used to download binaries. See {@link SmallBinaryRequest} and {@link BigBinaryRequest} @author jva
loadDataFromNetwork
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BinaryRequest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BinaryRequest.java
Apache-2.0
protected final String getUrl() { return this.url; }
Abstract class used to download binaries. See {@link SmallBinaryRequest} and {@link BigBinaryRequest} @author jva
getUrl
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BinaryRequest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BinaryRequest.java
Apache-2.0
protected void readBytes(final InputStream in, final ProgressByteProcessor processor) throws IOException { final byte[] buf = new byte[BUF_SIZE]; try { int amt; do { amt = in.read(buf); if (amt == -1) { break; } } while (processor.processBytes(buf, 0, amt)); } finally { IOUtils.closeQuietly(in); } }
Inspired from Guava com.google.common.io.ByteStreams
readBytes
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BinaryRequest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BinaryRequest.java
Apache-2.0
@Override public Bitmap loadDataFromNetwork() throws Exception { try { final HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(url).openConnection(); processStream(httpURLConnection.getContentLength(), httpURLConnection.getInputStream()); if (width != -1 && height != -1) { this.options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(cacheFile.getAbsolutePath(), options); options.inSampleSize = calculateInSampleSize(options, width, height); options.inJustDecodeBounds = false; options.inPurgeable = true; return BitmapFactory.decodeFile(cacheFile.getAbsolutePath(), options); } else { return BitmapFactory.decodeFile(cacheFile.getAbsolutePath(), options); } } catch (final MalformedURLException e) { Ln.e(e, "Unable to create URL"); throw e; } catch (final IOException e) { Ln.e(e, "Unable to download binary"); throw e; } }
Creates a BitmapRequest able to fetch a {@link Bitmap} from the network. @param url the url of the bitmap to fetch. @param width the requested width of the image. @param height the requested height of the image. @param cacheFile a file used to store data during download.
loadDataFromNetwork
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BitmapRequest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BitmapRequest.java
Apache-2.0
protected final String getUrl() { return this.url; }
Creates a BitmapRequest able to fetch a {@link Bitmap} from the network. @param url the url of the bitmap to fetch. @param width the requested width of the image. @param height the requested height of the image. @param cacheFile a file used to store data during download.
getUrl
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BitmapRequest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BitmapRequest.java
Apache-2.0
@Override public File getCacheFile() { return cacheFile; }
Creates a BitmapRequest able to fetch a {@link Bitmap} from the network. @param url the url of the bitmap to fetch. @param width the requested width of the image. @param height the requested height of the image. @param cacheFile a file used to store data during download.
getCacheFile
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BitmapRequest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BitmapRequest.java
Apache-2.0
public void processStream(int contentLength, final InputStream inputStream) throws IOException { OutputStream fileOutputStream = null; try { // touch boolean isTouchedNow = cacheFile.setLastModified(System.currentTimeMillis()); if (!isTouchedNow) { Ln.d("Modification time of file %s could not be changed normally ", cacheFile.getAbsolutePath()); } fileOutputStream = new FileOutputStream(cacheFile); readBytes(inputStream, new ProgressByteProcessor(this, fileOutputStream, contentLength)); } finally { IOUtils.closeQuietly(fileOutputStream); } }
Creates a BitmapRequest able to fetch a {@link Bitmap} from the network. @param url the url of the bitmap to fetch. @param width the requested width of the image. @param height the requested height of the image. @param cacheFile a file used to store data during download.
processStream
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BitmapRequest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BitmapRequest.java
Apache-2.0
protected void readBytes(final InputStream in, final ProgressByteProcessor processor) throws IOException { final byte[] buf = new byte[BUF_SIZE]; try { int amt; do { amt = in.read(buf); if (amt == -1) { break; } } while (processor.processBytes(buf, 0, amt)); } finally { IOUtils.closeQuietly(in); } }
Inspired from Guava com.google.common.io.ByteStreams
readBytes
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BitmapRequest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BitmapRequest.java
Apache-2.0
private static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > reqHeight || width > reqWidth) { if (width > height) { inSampleSize = Math.round((float) height / (float) reqHeight); } else { inSampleSize = Math.round((float) width / (float) reqWidth); } } return inSampleSize; }
Inspired from Guava com.google.common.io.ByteStreams
calculateInSampleSize
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BitmapRequest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/BitmapRequest.java
Apache-2.0
@Override public InputStream processStream(final int contentLength, final InputStream inputStream) throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); readBytes(inputStream, new ProgressByteProcessor(this, bos, contentLength)); final byte[] bytes = bos.toByteArray(); return new ByteArrayInputStream(bytes); }
Downloads small images in size. All data is passed to the listener using memory. This class is meant to help download small images (like thumbnails). If you wish to download bigger documents (or if you don't know the size of your documents), you would be better using {@link BigBinaryRequest}. @author sni & jva
processStream
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/SmallBinaryRequest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/SmallBinaryRequest.java
Apache-2.0
@Override public int getRetryCount() { return retryCount; }
The backoff multiplier. Will be multiplied by {@link #delayBeforeRetry} between every retry attempt.
getRetryCount
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/retry/DefaultRetryPolicy.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/retry/DefaultRetryPolicy.java
Apache-2.0
@Override public void retry(SpiceException e) { retryCount--; delayBeforeRetry = (long) (delayBeforeRetry * backOffMultiplier); }
The backoff multiplier. Will be multiplied by {@link #delayBeforeRetry} between every retry attempt.
retry
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/retry/DefaultRetryPolicy.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/retry/DefaultRetryPolicy.java
Apache-2.0
@Override public long getDelayBeforeRetry() { return delayBeforeRetry; }
The backoff multiplier. Will be multiplied by {@link #delayBeforeRetry} between every retry attempt.
getDelayBeforeRetry
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/retry/DefaultRetryPolicy.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/retry/DefaultRetryPolicy.java
Apache-2.0
@Override public void run() { try { super.run(); } catch (Exception ex) { this.ex = ex; } }
Class under test. Just a wrapper to get any exception that can occur in the spicemanager's thread. Inspired by http://stackoverflow.com/questions/ 2596493/junit-assert-in-thread-throws-exception/13712829#13712829
run
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/SpiceManagerTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/SpiceManagerTest.java
Apache-2.0
private CachedSpiceRequest<?> getNextRequest() { return requestQueue.peek(); }
Class under test. Just a wrapper to get any exception that can occur in the spicemanager's thread. Inspired by http://stackoverflow.com/questions/ 2596493/junit-assert-in-thread-throws-exception/13712829#13712829
getNextRequest
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/SpiceManagerTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/SpiceManagerTest.java
Apache-2.0
public Exception getException(long timeout) throws InterruptedException { runner.join(timeout); return ex; }
Class under test. Just a wrapper to get any exception that can occur in the spicemanager's thread. Inspired by http://stackoverflow.com/questions/ 2596493/junit-assert-in-thread-throws-exception/13712829#13712829
getException
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/SpiceManagerTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/SpiceManagerTest.java
Apache-2.0
@Override public CacheManager createCacheManager(Application application) { CacheManager cacheManager = new CacheManager(); StringPersisterStub stringPersisterStub = new StringPersisterStub(application); IntegerPersisterStub integerPersisterStub = new IntegerPersisterStub(application); DoubleInMemoryPersisterStub doubleInMemoryPersisterStub = new DoubleInMemoryPersisterStub(application); cacheManager.addPersister(stringPersisterStub); cacheManager.addPersister(integerPersisterStub); cacheManager.addPersister(doubleInMemoryPersisterStub); return cacheManager; }
Only used to test RoboSpice. Will not rely on network state. Multi-threaded spice service. @author sni
createCacheManager
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
Apache-2.0
@Override protected NetworkStateChecker getNetworkStateChecker() { return new NetworkStateChecker() { @Override public boolean isNetworkAvailable(Context context) { return true; } @Override public void checkPermissions(Context context) { // do nothing } }; }
Only used to test RoboSpice. Will not rely on network state. Multi-threaded spice service. @author sni
getNetworkStateChecker
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
Apache-2.0
@Override public boolean isNetworkAvailable(Context context) { return true; }
Only used to test RoboSpice. Will not rely on network state. Multi-threaded spice service. @author sni
isNetworkAvailable
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
Apache-2.0
@Override public void checkPermissions(Context context) { // do nothing }
Only used to test RoboSpice. Will not rely on network state. Multi-threaded spice service. @author sni
checkPermissions
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
Apache-2.0
@Override public int getThreadCount() { return TEST_THREAD_COUNT; }
Only used to test RoboSpice. Will not rely on network state. Multi-threaded spice service. @author sni
getThreadCount
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
Apache-2.0
@Override public int getCoreThreadCount() { return TEST_THREAD_COUNT; }
Only used to test RoboSpice. Will not rely on network state. Multi-threaded spice service. @author sni
getCoreThreadCount
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
Apache-2.0
@Override public int getMaximumThreadCount() { return TEST_THREAD_COUNT; }
Only used to test RoboSpice. Will not rely on network state. Multi-threaded spice service. @author sni
getMaximumThreadCount
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
Apache-2.0
@Override public int getThreadPriority() { return TEST_THREAD_PRIORITY; }
Only used to test RoboSpice. Will not rely on network state. Multi-threaded spice service. @author sni
getThreadPriority
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
Apache-2.0
@Override public int getKeepAliveTime() { return TEST_THREAD_KEEP_ALIVE_TIME; }
Only used to test RoboSpice. Will not rely on network state. Multi-threaded spice service. @author sni
getKeepAliveTime
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
Apache-2.0
@Override public boolean isFailOnCacheError() { return true; }
Only used to test RoboSpice. Will not rely on network state. Multi-threaded spice service. @author sni
isFailOnCacheError
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
Apache-2.0
@Override public Notification createDefaultNotification() { Notification notification = super.createDefaultNotification(); notification.icon = android.R.drawable.stat_sys_download; return notification; }
Only used to test RoboSpice. Will not rely on network state. Multi-threaded spice service. @author sni
createDefaultNotification
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
Apache-2.0
@Override public RequestProcessor getRequestProcessor() { return super.getRequestProcessor(); }
Only used to test RoboSpice. Will not rely on network state. Multi-threaded spice service. @author sni
getRequestProcessor
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/core/test/SpiceTestService.java
Apache-2.0
@Override protected void setUp() throws Exception { super.setUp(); mockWebServer = new MockWebServer(); cacheFile = new File(getContext().getCacheDir(), "test"); cacheFile.delete(); }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
setUp
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BigBinaryRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BigBinaryRequestTest.java
Apache-2.0
@Override protected void tearDown() throws Exception { mockWebServer.shutdown(); cacheFile.delete(); super.tearDown(); }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
tearDown
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BigBinaryRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BigBinaryRequestTest.java
Apache-2.0
public void test_loadDataFromNetwork_returns_a_binary() throws Exception { // given; byte[] data = IOUtils.toByteArray(getContext().getResources().openRawResource(R.raw.binary)); mockWebServer.enqueue(new MockResponse().setBody(data)); mockWebServer.play(); BigBinaryRequest binaryRequest = new BigBinaryRequest(mockWebServer.getUrl("/").toString(), cacheFile); InputStream binaryReturned = binaryRequest.loadDataFromNetwork(); InputStream cacheInputStream = new FileInputStream(cacheFile); // then assertTrue(IOUtils.contentEquals(binaryReturned, getContext().getResources().openRawResource(R.raw.binary))); assertTrue(IOUtils.contentEquals(cacheInputStream, getContext().getResources().openRawResource(R.raw.binary))); }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
test_loadDataFromNetwork_returns_a_binary
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BigBinaryRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BigBinaryRequestTest.java
Apache-2.0
@Override protected void setUp() throws Exception { super.setUp(); mockWebServer = new MockWebServer(); cacheFile = new File(getContext().getCacheDir(), "test"); cacheFile.delete(); }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
setUp
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BitmapRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BitmapRequestTest.java
Apache-2.0
@Override protected void tearDown() throws Exception { mockWebServer.shutdown(); cacheFile.delete(); super.tearDown(); }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
tearDown
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BitmapRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BitmapRequestTest.java
Apache-2.0
public void test_loadDataFromNetwork_returns_a_bitmap() throws Exception { // given; byte[] data = IOUtils.toByteArray(getContext().getResources().openRawResource(R.raw.binary)); mockWebServer.enqueue(new MockResponse().setBody(data)); mockWebServer.play(); BitmapRequest binaryRequest = new BitmapRequest(mockWebServer.getUrl("/").toString(), null, cacheFile); Bitmap bitmapReturned = binaryRequest.loadDataFromNetwork(); InputStream cacheInputStream = new FileInputStream(cacheFile); // then assertTrue(IOUtils.contentEquals(cacheInputStream, getContext().getResources().openRawResource(R.raw.binary))); assertEquals(TEST_BITMAP_WIDTH, bitmapReturned.getWidth()); assertEquals(TEST_BITMAP_HEIGHT, bitmapReturned.getHeight()); }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
test_loadDataFromNetwork_returns_a_bitmap
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BitmapRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BitmapRequestTest.java
Apache-2.0
public void test_loadDataFromNetwork_returns_a_bitmap_with_right_size() throws Exception { // given; byte[] data = IOUtils.toByteArray(getContext().getResources().openRawResource(R.raw.binary)); mockWebServer.enqueue(new MockResponse().setBody(data)); mockWebServer.play(); BitmapRequest binaryRequest = new BitmapRequest(mockWebServer.getUrl("/").toString(), TEST_BITMAP_REDUCED_WIDTH, TEST_BITMAP_REDUCED_HEIGHT, cacheFile); Bitmap bitmapReturned = binaryRequest.loadDataFromNetwork(); InputStream cacheInputStream = new FileInputStream(cacheFile); // then assertTrue(IOUtils.contentEquals(cacheInputStream, getContext().getResources().openRawResource(R.raw.binary))); assertEquals(TEST_BITMAP_REDUCED_WIDTH, bitmapReturned.getWidth()); assertEquals(TEST_BITMAP_REDUCED_HEIGHT, bitmapReturned.getHeight()); }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
test_loadDataFromNetwork_returns_a_bitmap_with_right_size
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BitmapRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BitmapRequestTest.java
Apache-2.0
public void test_loadDataFromNetwork_throws_exception() throws Exception { // given; mockWebServer.enqueue(new MockResponse().setResponseCode(HttpStatus.SC_NOT_FOUND)); mockWebServer.play(); // when BitmapRequest binaryRequest = new BitmapRequest(mockWebServer.getUrl("/").toString(), null, cacheFile); try { binaryRequest.loadDataFromNetwork(); // expected exception fail(); } catch (FileNotFoundException e) { // success return; } }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
test_loadDataFromNetwork_throws_exception
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BitmapRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/BitmapRequestTest.java
Apache-2.0
@Override protected void setUp() throws Exception { super.setUp(); mockWebServer = new MockWebServer(); }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
setUp
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SimpleTextRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SimpleTextRequestTest.java
Apache-2.0
@Override protected void tearDown() throws Exception { mockWebServer.shutdown(); super.tearDown(); }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
tearDown
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SimpleTextRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SimpleTextRequestTest.java
Apache-2.0
public void test_loadDataFromNetwork_returns_a_simple_string() throws Exception { // given; String loremIpsum = IOUtils.toString(getContext().getResources().openRawResource(R.raw.lorem_ipsum)); mockWebServer.enqueue(new MockResponse().setBody(loremIpsum)); mockWebServer.play(); // when SimpleTextRequest loremIpsumTextRequest = new SimpleTextRequest(mockWebServer.getUrl("/").toString()); String stringReturned = loremIpsumTextRequest.loadDataFromNetwork(); // then assertTrue(stringReturned.startsWith("Lorem ipsum")); }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
test_loadDataFromNetwork_returns_a_simple_string
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SimpleTextRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SimpleTextRequestTest.java
Apache-2.0
public void test_loadDataFromNetwork_throws_exception() throws Exception { // given; mockWebServer.enqueue(new MockResponse().setResponseCode(HttpStatus.SC_NOT_FOUND)); mockWebServer.play(); // when SimpleTextRequest loremIpsumTextRequest = new SimpleTextRequest(mockWebServer.getUrl("/").toString()); try { loremIpsumTextRequest.loadDataFromNetwork(); // expected exception fail(); } catch (FileNotFoundException e) { // success return; } }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
test_loadDataFromNetwork_throws_exception
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SimpleTextRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SimpleTextRequestTest.java
Apache-2.0
@Override protected void setUp() throws Exception { super.setUp(); mockWebServer = new MockWebServer(); }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
setUp
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SmallBinaryRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SmallBinaryRequestTest.java
Apache-2.0
@Override protected void tearDown() throws Exception { mockWebServer.shutdown(); super.tearDown(); }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
tearDown
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SmallBinaryRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SmallBinaryRequestTest.java
Apache-2.0
public void test_loadDataFromNetwork_returns_a_small_binary() throws Exception { // given; byte[] data = IOUtils.toByteArray(getContext().getResources().openRawResource(R.raw.binary)); mockWebServer.enqueue(new MockResponse().setBody(data)); mockWebServer.play(); // when SmallBinaryRequest binaryRequest = new SmallBinaryRequest(mockWebServer.getUrl("/").toString()); InputStream binaryReturned = binaryRequest.loadDataFromNetwork(); // then assertTrue(IOUtils.contentEquals(binaryReturned, getContext().getResources().openRawResource(R.raw.binary))); }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
test_loadDataFromNetwork_returns_a_small_binary
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SmallBinaryRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SmallBinaryRequestTest.java
Apache-2.0
public void test_loadDataFromNetwork_throws_exception() throws Exception { // given; mockWebServer.enqueue(new MockResponse().setResponseCode(HttpStatus.SC_NOT_FOUND)); mockWebServer.play(); // when SmallBinaryRequest binaryRequest = new SmallBinaryRequest(mockWebServer.getUrl("/").toString()); try { binaryRequest.loadDataFromNetwork(); // expected exception fail(); } catch (FileNotFoundException e) { // success return; } }
This test is a good example of how easy it is to test RoboSpice requests. Test is synchronous. @author sni
test_loadDataFromNetwork_throws_exception
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SmallBinaryRequestTest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/request/SmallBinaryRequestTest.java
Apache-2.0
public void await(long millisecond) throws InterruptedException { ((SpiceRequestStub<?>) getSpiceRequest()).awaitForLoadDataFromNetworkIsCalled(millisecond); }
@see {@link SpiceRequestStub#awaitForLoadDataFromNetworkIsCalled(long)}. @param millisecond @throws InterruptedException
await
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/CachedSpiceRequestStub.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/CachedSpiceRequestStub.java
Apache-2.0
@Override public Double loadDataFromCache(Object cacheKey, long maxTimeInCache) throws CacheLoadingException { if (maxTimeInCache == DurationInMillis.ALWAYS_EXPIRED || maxTimeInCache > DurationInMillis.ONE_MINUTE) { return null; } Ln.d("Value in cache for " + cacheKey + " is " + map.get(cacheKey)); return map.get(cacheKey); }
Stub of an object persister. This one stores double in hashmap to implement caching. @author sni
loadDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
Apache-2.0
@Override public List<Double> loadAllDataFromCache() throws CacheLoadingException { return new ArrayList<Double>(map.values()); }
Stub of an object persister. This one stores double in hashmap to implement caching. @author sni
loadAllDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
Apache-2.0
@Override public List<Object> getAllCacheKeys() { return new ArrayList<Object>(map.keySet()); }
Stub of an object persister. This one stores double in hashmap to implement caching. @author sni
getAllCacheKeys
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
Apache-2.0
@Override public Double saveDataToCacheAndReturnData(Double data, Object cacheKey) throws CacheSavingException { Ln.d("Adding " + data + " to cache at " + cacheKey); map.put(cacheKey, data); return data; }
Stub of an object persister. This one stores double in hashmap to implement caching. @author sni
saveDataToCacheAndReturnData
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
Apache-2.0
@Override public boolean removeDataFromCache(Object cacheKey) { Ln.d("Clearing cache at" + cacheKey); map.remove(cacheKey); return true; }
Stub of an object persister. This one stores double in hashmap to implement caching. @author sni
removeDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
Apache-2.0
@Override public void removeAllDataFromCache() { Ln.d("Clearing all cache"); map.clear(); }
Stub of an object persister. This one stores double in hashmap to implement caching. @author sni
removeAllDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
Apache-2.0
@Override public long getCreationDateInCache(Object cacheKey) throws CacheLoadingException { return 0; }
Stub of an object persister. This one stores double in hashmap to implement caching. @author sni
getCreationDateInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
Apache-2.0
@Override public boolean isDataInCache(Object cacheKey, long maxTimeInCache) { return maxTimeInCache != DurationInMillis.ALWAYS_EXPIRED && maxTimeInCache < DurationInMillis.ONE_MINUTE; }
Stub of an object persister. This one stores double in hashmap to implement caching. @author sni
isDataInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/DoubleInMemoryPersisterStub.java
Apache-2.0
@Override public Integer loadDataFromCache(Object cacheKey, long maxTimeInCache) throws CacheLoadingException { if (maxTimeInCache == DurationInMillis.ALWAYS_EXPIRED || maxTimeInCache > DurationInMillis.ONE_MINUTE) { return null; } return STUB_DATA; }
Stub of an object persister. Doesn't use any real cache management. Will help to pass the tests without any side-effect. @author sni
loadDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/IntegerPersisterStub.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/IntegerPersisterStub.java
Apache-2.0