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 |
|---|---|---|---|---|---|---|---|
protected final String fromKey(String cacheKey) {
if (isUsingKeySanitizer()) {
try {
return (String) keySanitizer.desanitizeKey(cacheKey);
} catch (KeySanitationExcepion e) {
Ln.e(e, "Key could not be desanitized, falling back on original key.");
... | Get a cache key that may be de-sanitized if a {@link KeySanitizer} is
used.
@param cacheKey
a possibly sanitized cacheKey.
@return a key that will be de-sanitized if a {@link KeySanitizer} is
used. | fromKey | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersister.java | Apache-2.0 |
protected final String getCachePrefix() {
return factoryCachePrefix + getClass().getSimpleName() + CACHE_PREFIX_END + getHandledClass().getSimpleName() + CACHE_PREFIX_END;
} | Get a cache key that may be de-sanitized if a {@link KeySanitizer} is
used.
@param cacheKey
a possibly sanitized cacheKey.
@return a key that will be de-sanitized if a {@link KeySanitizer} is
used. | getCachePrefix | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersister.java | Apache-2.0 |
protected boolean isCachedAndNotExpired(Object cacheKey, long maxTimeInCacheBeforeExpiry) {
File cacheFile = getCacheFile(cacheKey);
return isCachedAndNotExpired(cacheFile, maxTimeInCacheBeforeExpiry);
} | Get a cache key that may be de-sanitized if a {@link KeySanitizer} is
used.
@param cacheKey
a possibly sanitized cacheKey.
@return a key that will be de-sanitized if a {@link KeySanitizer} is
used. | isCachedAndNotExpired | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersister.java | Apache-2.0 |
protected boolean isCachedAndNotExpired(File cacheFile, long maxTimeInCacheBeforeExpiry) {
if (cacheFile.exists()) {
long timeInCache = System.currentTimeMillis() - cacheFile.lastModified();
if (maxTimeInCacheBeforeExpiry == DurationInMillis.ALWAYS_RETURNED || timeInCache <= maxTimeInCac... | Get a cache key that may be de-sanitized if a {@link KeySanitizer} is
used.
@param cacheKey
a possibly sanitized cacheKey.
@return a key that will be de-sanitized if a {@link KeySanitizer} is
used. | isCachedAndNotExpired | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersister.java | Apache-2.0 |
public void setCacheFolder(File cacheFolder) throws CacheCreationException {
if (cacheFolder == null) {
cacheFolder = new File(getApplication().getCacheDir(), InFileObjectPersister.DEFAULT_ROOT_CACHE_DIR);
}
this.cacheFolder = cacheFolder;
if (!cacheFolder.exists() && !cache... | Sets the folder used by object persisters of this factory.
@param cacheFolder
the new cache folder of this factory (and persisters it will
create). Ca be null, it will then default to the sub folder
{@link InFileObjectPersister#DEFAULT_ROOT_CACHE_DIR} in side
the application ... | setCacheFolder | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | Apache-2.0 |
public void setCachePrefix(String cachePrefix) {
this.cachePrefix = cachePrefix;
} | Sets the cachePrefix used by object persisters of this factory.
@param cachePrefix
the new cache cachePrefix of this factory (and persisters it
will create). Defaults to "className". | setCachePrefix | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | Apache-2.0 |
public File getCacheFolder() {
return cacheFolder;
} | Sets the cachePrefix used by object persisters of this factory.
@param cachePrefix
the new cache cachePrefix of this factory (and persisters it
will create). Defaults to "className". | getCacheFolder | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | Apache-2.0 |
public String getCachePrefix() {
return cachePrefix;
} | Sets the cachePrefix used by object persisters of this factory.
@param cachePrefix
the new cache cachePrefix of this factory (and persisters it
will create). Defaults to "className". | getCachePrefix | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | Apache-2.0 |
public KeySanitizer getKeySanitizer() {
return keySanitizer;
} | Sets the cachePrefix used by object persisters of this factory.
@param cachePrefix
the new cache cachePrefix of this factory (and persisters it
will create). Defaults to "className". | getKeySanitizer | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | Apache-2.0 |
public void setKeySanitizer(KeySanitizer keySanitizer) {
this.keySanitizer = keySanitizer;
} | @param keySanitizer
the new key sanitizer to be used by this
{@link InFileObjectPersisterFactory} and persisters. May be
null, in that case no key sanitation will be used. This is the
default. | setKeySanitizer | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | Apache-2.0 |
@Override
public final <T> InFileObjectPersister<T> createObjectPersister(Class<T> clazz) {
InFileObjectPersister<T> inFileObjectPersister;
try {
inFileObjectPersister = createInFileObjectPersister(clazz, cacheFolder);
inFileObjectPersister.setFactoryCachePrefix(cachePrefix)... | @param keySanitizer
the new key sanitizer to be used by this
{@link InFileObjectPersisterFactory} and persisters. May be
null, in that case no key sanitation will be used. This is the
default. | createObjectPersister | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | Apache-2.0 |
@Override
public void removeAllDataFromCache() {
File cacheFolder = getCacheFolder();
File[] cacheFileList = cacheFolder.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return file.getName().startsWith(getCachePrefix());
... | @param keySanitizer
the new key sanitizer to be used by this
{@link InFileObjectPersisterFactory} and persisters. May be
null, in that case no key sanitation will be used. This is the
default. | removeAllDataFromCache | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | Apache-2.0 |
@Override
public boolean accept(File file) {
return file.getName().startsWith(getCachePrefix());
} | @param keySanitizer
the new key sanitizer to be used by this
{@link InFileObjectPersisterFactory} and persisters. May be
null, in that case no key sanitation will be used. This is the
default. | accept | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/file/InFileObjectPersisterFactory.java | Apache-2.0 |
@Override
public Object sanitizeKey(Object cacheKey) throws KeySanitationExcepion {
if (!(cacheKey instanceof String)) {
throw new KeySanitationExcepion(DefaultKeySanitizer.class.getSimpleName() + " can only be used with Strings cache keys.");
}
try {
return Base64.en... | Uses base 64 to sanitize/de-sanitize keys. Only applies to cache keys that
are strings. Keys sanitized by this class can be safely used to create file
names (and urls).
@author SNI | sanitizeKey | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/keysanitation/DefaultKeySanitizer.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/keysanitation/DefaultKeySanitizer.java | Apache-2.0 |
@Override
public Object desanitizeKey(Object sanitzedCacheKey) throws KeySanitationExcepion {
if (!(sanitzedCacheKey instanceof String)) {
throw new KeySanitationExcepion(DefaultKeySanitizer.class.getSimpleName() + " can only be used with Strings cache keys.");
}
try {
... | Uses base 64 to sanitize/de-sanitize keys. Only applies to cache keys that
are strings. Keys sanitized by this class can be safely used to create file
names (and urls).
@author SNI | desanitizeKey | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/keysanitation/DefaultKeySanitizer.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/keysanitation/DefaultKeySanitizer.java | Apache-2.0 |
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
@Override
protected int sizeOf(Object key, CacheItem<Bitmap> value) {
Bitmap data = value.getData();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) {
return data.getRowBytes() * data.getHeight();
} else {
... | {@link LruCache} for {@link Bitmap}s.
@author David Stemmer
@author Mike Jancola
@author SNI | sizeOf | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/BitmapLruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/BitmapLruCache.java | Apache-2.0 |
public long getCreationDate() {
return creationDate;
} | The CacheItem class represents a cached object, consisting of a piece of data
and a time stamp marking when the data was added to the cache.
@param <T>
the type of object that will be stored in the cache. | getCreationDate | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/CacheItem.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/CacheItem.java | Apache-2.0 |
public T getData() {
return data;
} | The CacheItem class represents a cached object, consisting of a piece of data
and a time stamp marking when the data was added to the cache.
@param <T>
the type of object that will be stored in the cache. | getData | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/CacheItem.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/CacheItem.java | Apache-2.0 |
public final V get(K key) {
if (key == null) {
throw new NullPointerException("key == null");
}
V mapValue;
synchronized (this) {
mapValue = map.get(key);
if (mapValue != null) {
hitCount++;
return mapValue;
... | Returns the value for {@code key} if it exists in the cache or can be
created by {@code #create}. If a value was returned, it is moved to the
head of the queue. This returns null if a value is not cached and cannot
be created. | get | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
public final V put(K key, V value) {
if (key == null || value == null) {
throw new NullPointerException("key == null || value == null");
}
V previous;
synchronized (this) {
putCount++;
size += safeSizeOf(key, value);
previous = map.put(key... | Caches {@code value} for {@code key}. The value is moved to the head of
the queue.
@return the previous value mapped by {@code key}. | put | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
public void trimToSize(int maxSize) {
while (true) {
K key;
V value;
synchronized (this) {
if (size < 0 || map.isEmpty() && size != 0) {
throw new IllegalStateException(getClass().getName() + ".sizeOf() is reporting inconsistent results!");... | Remove the eldest entries until the total of remaining entries is at or
below the requested size.
@param maxSize
the maximum size of the cache before returning. May be -1 to
evict even 0-sized elements. | trimToSize | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
public final V remove(K key) {
if (key == null) {
throw new NullPointerException("key == null");
}
V previous;
synchronized (this) {
previous = map.remove(key);
if (previous != null) {
size -= safeSizeOf(key, previous);
}
... | Removes the entry for {@code key} if it exists.
@return the previous value mapped by {@code key}. | remove | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
protected V create(K key) {
return null;
} | Called after a cache miss to compute a value for the corresponding key.
Returns the computed value or null if no value can be computed. The
default implementation returns null.
<p>
The method is called without synchronization: other threads may access
the cache while this method is executing.
<p>
If a value for {@code ... | create | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
private int safeSizeOf(K key, V value) {
int result = sizeOf(key, value);
if (result < 0) {
throw new IllegalStateException("Negative size: " + key + "=" + value);
}
return result;
} | Called after a cache miss to compute a value for the corresponding key.
Returns the computed value or null if no value can be computed. The
default implementation returns null.
<p>
The method is called without synchronization: other threads may access
the cache while this method is executing.
<p>
If a value for {@code ... | safeSizeOf | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
protected int sizeOf(K key, V value) {
return 1;
} | Returns the size of the entry for {@code key} and {@code value} in
user-defined units. The default implementation returns 1 so that size is
the number of entries and max size is the maximum number of entries.
<p>
An entry's size must not change while it is in the cache. | sizeOf | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
public final void evictAll() {
trimToSize(-1); // -1 will evict 0-sized elements
} | Clear the cache, calling {@link #entryRemoved} on each removed entry. | evictAll | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
public final synchronized int size() {
return size;
} | For caches that do not override {@link #sizeOf}, this returns the number
of entries in the cache. For all other caches, this returns the sum of
the sizes of the entries in this cache. | size | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
public final synchronized int maxSize() {
return maxSize;
} | For caches that do not override {@link #sizeOf}, this returns the maximum
number of entries in the cache. For all other caches, this returns the
maximum sum of the sizes of the entries in this cache. | maxSize | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
public final synchronized int hitCount() {
return hitCount;
} | Returns the number of times {@link #get} returned a value. | hitCount | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
public final synchronized int missCount() {
return missCount;
} | Returns the number of times {@link #get} returned null or required a new
value to be created. | missCount | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
public final synchronized int createCount() {
return createCount;
} | Returns the number of times {@link #create(Object)} returned a value. | createCount | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
public final synchronized int putCount() {
return putCount;
} | Returns the number of times {@link #put} was called. | putCount | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
public final synchronized int evictionCount() {
return evictionCount;
} | Returns the number of values that have been evicted. | evictionCount | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
public final synchronized Map<K, V> snapshot() {
return new LinkedHashMap<K, V>(map);
} | Returns a copy of the current contents of the cache, ordered from least
recently accessed to most recently accessed. | snapshot | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
@Override
public final synchronized String toString() {
int accesses = hitCount + missCount;
int hitPercent = accesses != 0 ? MAX_PERCENT * hitCount / accesses : 0;
return String.format("LruCache[maxSize=%d,hits=%d,misses=%d,hitRate=%d%%]", maxSize, hitCount, missCount, hitPercent);
} | Returns a copy of the current contents of the cache, ordered from least
recently accessed to most recently accessed. | toString | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCache.java | Apache-2.0 |
public ObjectPersister<T> getDecoratedPersister() {
return decoratedPersister;
} | Abstract in-memory object persister, based on the Android LRUCache.
@author David Stemmer
@author Mike Jancola | getDecoratedPersister | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | Apache-2.0 |
public LruCache<Object, CacheItem<T>> getLruCache() {
return lruCache;
} | Abstract in-memory object persister, based on the Android LRUCache.
@author David Stemmer
@author Mike Jancola | getLruCache | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | Apache-2.0 |
@Override
public T loadDataFromCache(Object cacheKey, long maxTimeInCacheBeforeExpiry) throws CacheLoadingException {
CacheItem<T> cacheItem = lruCache.get(cacheKey);
if (cacheItem == null) {
Ln.d("Miss from lru cache for %s", cacheKey);
if (decoratedPersister != null) {
... | Abstract in-memory object persister, based on the Android LRUCache.
@author David Stemmer
@author Mike Jancola | loadDataFromCache | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | Apache-2.0 |
@Override
public T saveDataToCacheAndReturnData(T data, Object cacheKey) throws CacheSavingException {
CacheItem<T> itemToCache = new CacheItem<T>(data);
lruCache.put(cacheKey, itemToCache);
Ln.d("Put in lru cache for %s", cacheKey);
if (decoratedPersister != null) {
dec... | Abstract in-memory object persister, based on the Android LRUCache.
@author David Stemmer
@author Mike Jancola | saveDataToCacheAndReturnData | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | Apache-2.0 |
@Override
public boolean isDataInCache(Object cacheKey, long maxTimeInCacheBeforeExpiry) {
CacheItem<T> cacheItem = lruCache.get(cacheKey);
if (cacheItem == null) {
if (decoratedPersister != null) {
return decoratedPersister.isDataInCache(cacheKey, maxTimeInCacheBeforeEx... | Abstract in-memory object persister, based on the Android LRUCache.
@author David Stemmer
@author Mike Jancola | isDataInCache | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | Apache-2.0 |
@Override
public long getCreationDateInCache(Object cacheKey) throws CacheLoadingException {
CacheItem<T> cacheItem = lruCache.get(cacheKey);
if (cacheItem != null) {
return cacheItem.getCreationDate();
} else {
if (decoratedPersister != null) {
retur... | Abstract in-memory object persister, based on the Android LRUCache.
@author David Stemmer
@author Mike Jancola | getCreationDateInCache | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | Apache-2.0 |
@Override
public List<T> loadAllDataFromCache() throws CacheLoadingException {
if (decoratedPersister != null) {
return decoratedPersister.loadAllDataFromCache();
} else {
Map<Object, CacheItem<T>> cacheMap = lruCache.snapshot();
List<T> allData = new ArrayList<T>... | Abstract in-memory object persister, based on the Android LRUCache.
@author David Stemmer
@author Mike Jancola | loadAllDataFromCache | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | Apache-2.0 |
@Override
public List<Object> getAllCacheKeys() {
if (decoratedPersister != null) {
return decoratedPersister.getAllCacheKeys();
} else {
return new ArrayList<Object>(lruCache.snapshot().keySet());
}
} | Abstract in-memory object persister, based on the Android LRUCache.
@author David Stemmer
@author Mike Jancola | getAllCacheKeys | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | Apache-2.0 |
@Override
public boolean removeDataFromCache(Object cacheKey) {
boolean result = false;
if (decoratedPersister != null) {
result = decoratedPersister.removeDataFromCache(cacheKey);
}
return result || lruCache.remove(cacheKey) != null;
} | Abstract in-memory object persister, based on the Android LRUCache.
@author David Stemmer
@author Mike Jancola | removeDataFromCache | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | Apache-2.0 |
@Override
public void removeAllDataFromCache() {
lruCache.evictAll();
if (decoratedPersister != null) {
decoratedPersister.removeAllDataFromCache();
}
} | Abstract in-memory object persister, based on the Android LRUCache.
@author David Stemmer
@author Mike Jancola | removeAllDataFromCache | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/LruCacheObjectPersister.java | Apache-2.0 |
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
@Override
protected int sizeOf(Object key, CacheItem<String> value) {
String data = value.getData();
return data.length();
} | {@link LruCache} for {@link String}.
@author David Stemmer
@author Mike Jancola
@author SNI | sizeOf | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/StringLruCache.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/memory/StringLruCache.java | Apache-2.0 |
public static int v(Throwable t) {
return CONFIG.minimumLogLevel <= Log.VERBOSE ? print.println(Log.VERBOSE, Log.getStackTraceString(t)) : 0;
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | v | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int v(Object s1, Object... args) {
if (CONFIG.minimumLogLevel > Log.VERBOSE) {
return 0;
}
final String s = Strings.toString(s1);
final String message = args.length > 0 ? String.format(s, args) : s;
return print.println(Log.VERBOSE, message);
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | v | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int v(Throwable throwable, Object s1, Object... args) {
if (CONFIG.minimumLogLevel > Log.VERBOSE) {
return 0;
}
final String s = Strings.toString(s1);
final String message = (args.length > 0 ? String.format(s, args) : s) + '\n' + Log.getStackTraceString(throwab... | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | v | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int d(Throwable t) {
return CONFIG.minimumLogLevel <= Log.DEBUG ? print.println(Log.DEBUG, Log.getStackTraceString(t)) : 0;
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | d | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int d(Object s1, Object... args) {
if (CONFIG.minimumLogLevel > Log.DEBUG) {
return 0;
}
final String s = Strings.toString(s1);
final String message = args.length > 0 ? String.format(s, args) : s;
return print.println(Log.DEBUG, message);
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | d | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int d(Throwable throwable, Object s1, Object... args) {
if (CONFIG.minimumLogLevel > Log.DEBUG) {
return 0;
}
final String s = Strings.toString(s1);
final String message = (args.length > 0 ? String.format(s, args) : s) + '\n' + Log.getStackTraceString(throwable... | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | d | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int i(Throwable t) {
return CONFIG.minimumLogLevel <= Log.INFO ? print.println(Log.INFO, Log.getStackTraceString(t)) : 0;
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | i | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int i(Object s1, Object... args) {
if (CONFIG.minimumLogLevel > Log.INFO) {
return 0;
}
final String s = Strings.toString(s1);
final String message = args.length > 0 ? String.format(s, args) : s;
return print.println(Log.INFO, message);
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | i | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int i(Throwable throwable, Object s1, Object... args) {
if (CONFIG.minimumLogLevel > Log.INFO) {
return 0;
}
final String s = Strings.toString(s1);
final String message = (args.length > 0 ? String.format(s, args) : s) + '\n' + Log.getStackTraceString(throwable)... | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | i | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int w(Throwable t) {
return CONFIG.minimumLogLevel <= Log.WARN ? print.println(Log.WARN, Log.getStackTraceString(t)) : 0;
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | w | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int w(Object s1, Object... args) {
if (CONFIG.minimumLogLevel > Log.WARN) {
return 0;
}
final String s = Strings.toString(s1);
final String message = args.length > 0 ? String.format(s, args) : s;
return print.println(Log.WARN, message);
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | w | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int w(Throwable throwable, Object s1, Object... args) {
if (CONFIG.minimumLogLevel > Log.WARN) {
return 0;
}
final String s = Strings.toString(s1);
final String message = (args.length > 0 ? String.format(s, args) : s) + '\n' + Log.getStackTraceString(throwable)... | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | w | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int e(Throwable t) {
return CONFIG.minimumLogLevel <= Log.ERROR ? print.println(Log.ERROR, Log.getStackTraceString(t)) : 0;
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | e | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int e(Object s1, Object... args) {
if (CONFIG.minimumLogLevel > Log.ERROR) {
return 0;
}
final String s = Strings.toString(s1);
final String message = args.length > 0 ? String.format(s, args) : s;
return print.println(Log.ERROR, message);
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | e | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static int e(Throwable throwable, Object s1, Object... args) {
if (CONFIG.minimumLogLevel > Log.ERROR) {
return 0;
}
final String s = Strings.toString(s1);
final String message = (args.length > 0 ? String.format(s, args) : s) + '\n' + Log.getStackTraceString(throwable... | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | e | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static boolean isDebugEnabled() {
return CONFIG.minimumLogLevel <= Log.DEBUG;
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | isDebugEnabled | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static boolean isVerboseEnabled() {
return CONFIG.minimumLogLevel <= Log.VERBOSE;
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | isVerboseEnabled | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static Config getConfig() {
return CONFIG;
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | getConfig | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
@Override
public int getLoggingLevel() {
return minimumLogLevel;
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | getLoggingLevel | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
@Override
public void setLoggingLevel(int level) {
minimumLogLevel = level;
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | setLoggingLevel | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static String logLevelToString(int loglevel) {
switch (loglevel) {
case Log.VERBOSE:
return "VERBOSE";
case Log.DEBUG:
return "DEBUG";
case Log.INFO:
return "INFO";
case Log.WARN:
return "WARN"... | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | logLevelToString | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public static void setPrint(Print print) {
Ln.print = print;
} | print is initially set to Print(), then replaced by guice during static
injection pass. This allows overriding where the log message is delivered
to. | setPrint | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
public int println(int priority, String msg) {
return Log.println(priority, getScope(), processMessage(msg));
} | Default implementation logs to android.util.Log | println | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
protected String processMessage(String msg) {
if (CONFIG.minimumLogLevel <= Log.DEBUG) {
msg = String.format("%s %s %s", new SimpleDateFormat("HH:mm:ss.SSS").format(System.currentTimeMillis()), Thread.currentThread().getName(), msg);
}
return msg;
} | Default implementation logs to android.util.Log | processMessage | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
protected static String getScope() {
if (CONFIG.minimumLogLevel <= Log.DEBUG) {
final StackTraceElement trace = Thread.currentThread().getStackTrace()[DEFAULT_STACK_TRACE_LINE_COUNT];
return CONFIG.scope + "/" + trace.getFileName() + ":" + trace.getLineNumber();
}... | Default implementation logs to android.util.Log | getScope | java | stephanenicolas/robospice | robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/roboguice/util/temp/Ln.java | Apache-2.0 |
@Override
protected void onStart() {
spiceManager.start(this);
super.onStart();
} | This class is more a sample than a real ready-to-use class. It shows how you
can build your base Activity class in your own project. Whatever super class
you use (sherlock, fragmentactivity, guice, etc.) you can just copy past the
methods below to enable all your activities to use the framework. The binding
can take pl... | onStart | java | stephanenicolas/robospice | robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceActivity.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceActivity.java | Apache-2.0 |
@Override
protected void onStop() {
spiceManager.shouldStop();
super.onStop();
} | This class is more a sample than a real ready-to-use class. It shows how you
can build your base Activity class in your own project. Whatever super class
you use (sherlock, fragmentactivity, guice, etc.) you can just copy past the
methods below to enable all your activities to use the framework. The binding
can take pl... | onStop | java | stephanenicolas/robospice | robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceActivity.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceActivity.java | Apache-2.0 |
public SpiceManager getSpiceManager() {
return spiceManager;
} | This class is more a sample than a real ready-to-use class. It shows how you
can build your base Activity class in your own project. Whatever super class
you use (sherlock, fragmentactivity, guice, etc.) you can just copy past the
methods below to enable all your activities to use the framework. The binding
can take pl... | getSpiceManager | java | stephanenicolas/robospice | robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceActivity.java | https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceActivity.java | Apache-2.0 |
protected int getThreadCount() {
return DEFAULT_THREAD_COUNT;
} | Number of threads used internally by this spice manager to communicate
commands to the SpiceService it is bound to
@return the thread count. Defaults to {@link #DEFAULT_THREAD_COUNT}. | getThreadCount | 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 synchronized void start(final Context context) {
this.contextWeakReference = new WeakReference<Context>(context);
if (isStarted()) {
throw new IllegalStateException("Already started.");
} else {
executorService = Executors.newFixedThreadPool(getThreadCount(), new M... | Start the {@link SpiceManager}. It will bind asynchronously to the
{@link SpiceService}.
@param context
a context that will be used to bind to the service. Typically,
the Activity or Fragment that needs to interact with the
{@link SpiceService}. | start | 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 synchronized boolean isStarted() {
return !isStopped;
} | Method is synchronized with {@link #start(Context)}.
@return whether or not the {@link SpiceManager} is started. | isStarted | 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 int getRequestToLaunchCount() {
return mapRequestToLaunchToRequestListener.size();
} | @return the number of current requests that should be launched ASAP (when
the spice service is bound). | getRequestToLaunchCount | 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 int getPendingRequestCount() {
return mapPendingRequestToRequestListener.size();
} | @return the number of current request that are currently pending and
being processed by the spice service. | getPendingRequestCount | 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 Context getContextReference() {
return contextWeakReference.get();
} | @return the number of current request that are currently pending and
being processed by the spice service. | getContextReference | 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() {
if (!tryToStartService()) {
Ln.d("Service was not started as Activity died prematurely");
isStopped = true;
return;
}
bindToService();
try {
waitForServiceToBeBound();
if (spiceService == nul... | @return the number of current request that are currently pending and
being processed by the spice service. | 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 |
private void sendRequestToService(final CachedSpiceRequest<?> spiceRequest) {
lockSendRequestsToService.lock();
try {
if (spiceRequest != null && spiceService != null) {
if (isStopped) {
Ln.d("Sending request to service without listeners : " + spiceRequest... | @return the number of current request that are currently pending and
being processed by the spice service. | sendRequestToService | 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 synchronized void shouldStop() {
try {
shouldStopAndJoin(DELAY_WAIT_FOR_RUNNER_TO_STOP);
} catch (InterruptedException e) {
Ln.e(e, "Exception when joining the runner that was stopping.");
}
} | Stops the {@link SpiceManager}. It will unbind from {@link SpiceService}.
All request listeners that had been registered to listen to
{@link SpiceRequest}s sent from this {@link SpiceManager} will be
unregistered. None of them will be notified with the results of their
{@link SpiceRequest}s. Unbinding will occur asynch... | shouldStop | 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 synchronized void shouldStopAndJoin(final long timeOut) throws InterruptedException {
if (!isStarted()) {
throw new IllegalStateException("Not started yet");
}
Ln.d("SpiceManager stopping. Joining");
this.isStopped = true;
dontNotifyAnyRequestListenersInternal... | This is mostly a testing method. Stops the {@link SpiceManager}. It will
unbind from {@link SpiceService}. All request listeners that had been
registered to listen to {@link SpiceRequest}s sent from this
{@link SpiceManager} will be unregistered. None of them will be notified
with the results of their {@link SpiceReque... | shouldStopAndJoin | 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> void getFromCache(final Class<T> clazz, final Object requestCacheKey, final long cacheExpiryDuration, final RequestListener<T> requestListener) {
final SpiceRequest<T> request = new SpiceRequest<T>(clazz) {
@Override
public T loadDataFromNetwork() throws Exception {
... | Get some data previously saved in cache with key <i>requestCacheKey</i>
with maximum time in cache : <i>cacheDuration</i> millisecond and
register listeners to notify when request is finished. This method
executes a SpiceRequest with no network processing. It just checks
whatever is in the cache and return it, includin... | getFromCache | 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 loadDataFromNetwork() throws Exception {
return null;
} | Get some data previously saved in cache with key <i>requestCacheKey</i>
with maximum time in cache : <i>cacheDuration</i> millisecond and
register listeners to notify when request is finished. This method
executes a SpiceRequest with no network processing. It just checks
whatever is in the cache and return it, includin... | loadDataFromNetwork | 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 boolean isAggregatable() {
return false;
} | Get some data previously saved in cache with key <i>requestCacheKey</i>
with maximum time in cache : <i>cacheDuration</i> millisecond and
register listeners to notify when request is finished. This method
executes a SpiceRequest with no network processing. It just checks
whatever is in the cache and return it, includin... | isAggregatable | 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> void addListenerIfPending(final Class<T> clazz, final Object requestCacheKey, final PendingRequestListener<T> requestListener) {
addListenerIfPending(clazz, requestCacheKey, (RequestListener<T>) requestListener);
} | Add listener to a pending request if it exists. If no such request
exists, this method calls onRequestNotFound on the listener. If a request
identified by clazz and requestCacheKey, it will receive an additional
listener.
@param clazz
the class of the result of the pending request to look for.
@param request... | addListenerIfPending | 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> void execute(final SpiceRequest<T> request, final RequestListener<T> requestListener) {
final CachedSpiceRequest<T> cachedSpiceRequest = new CachedSpiceRequest<T>(request, null, DurationInMillis.ALWAYS_RETURNED);
execute(cachedSpiceRequest, requestListener);
} | Execute a request, without using cache. No result from cache will be
returned. The method {@link SpiceRequest#loadDataFromNetwork()} will
always be invoked. The result will not be stored in cache.
@param request
the request to execute.
@param requestListener
the listener to notify when the request... | execute | 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> void execute(final SpiceRequest<T> request, final Object requestCacheKey, final long cacheExpiryDuration, final RequestListener<T> requestListener) {
final CachedSpiceRequest<T> cachedSpiceRequest = new CachedSpiceRequest<T>(request, requestCacheKey, cacheExpiryDuration);
execute(cachedSpiceR... | Execute a request. Before invoking the method
{@link SpiceRequest#loadDataFromNetwork()}, the cache will be checked :
if a result has been cached with the cache key <i>requestCacheKey</i>,
RoboSpice will consider the parameter <i>cacheExpiryDuration</i> to
determine whether the result in the cache is expired or not. If... | execute | 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> void execute(final CachedSpiceRequest<T> cachedSpiceRequest, final RequestListener<T> requestListener) {
addRequestListenerToListOfRequestListeners(cachedSpiceRequest, requestListener);
Ln.d("adding request to request queue");
this.requestQueue.add(cachedSpiceRequest);
} | Execute a request, put the result in cache and register listeners to
notify when request is finished.
@param cachedSpiceRequest
the request to execute. {@link CachedSpiceRequest} is a
wrapper of {@link SpiceRequest} that contains cache key and
cache duration
@param requestListener
... | execute | 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> void getFromCacheAndLoadFromNetworkIfExpired(final SpiceRequest<T> request, final Object requestCacheKey, final long cacheExpiryDuration, final RequestListener<T> requestListener) {
final CachedSpiceRequest<T> cachedSpiceRequest = new CachedSpiceRequest<T>(request, requestCacheKey, cacheExpiryDuratio... | Gets data from cache, expired or not, and executes a request normaly.
Before invoking the method {@link SpiceRequest#loadDataFromNetwork()},
the cache will be checked : if a result has been cached with the cache
key <i>requestCacheKey</i>, RoboSpice will consider the parameter
<i>cacheExpiryDuration</i> to determine wh... | getFromCacheAndLoadFromNetworkIfExpired | 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 <U, T extends U> void putInCache(final Class<U> clazz, final Object requestCacheKey, final T data, RequestListener<U> listener) {
@SuppressWarnings({ "unchecked", "rawtypes" })
final SpiceRequest<U> spiceRequest = new SpiceRequest(clazz) {
@Override
public U loadDataFromNe... | Adds some data to the cache, asynchronously.
@param clazz
a super class or the class of data.
@param requestCacheKey
the request cache key that data will be stored in.
@param data
the data to store. Maybe null if supported by underlying
ObjectPersister.
@param listener
... | putInCache | 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 U loadDataFromNetwork() throws Exception {
return data;
} | Adds some data to the cache, asynchronously.
@param clazz
a super class or the class of data.
@param requestCacheKey
the request cache key that data will be stored in.
@param data
the data to store. Maybe null if supported by underlying
ObjectPersister.
@param listener
... | loadDataFromNetwork | 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> void putInCache(final Class<? super T> clazz, final Object requestCacheKey, final T data) {
putInCache(clazz, requestCacheKey, data, null);
} | Adds some data to the cache, asynchronously. Same as
{@link #putInCache(Class, Object, Object, RequestListener)} with a null
listener. Operation will take place but you won't be notified.
@param clazz
a super class or the class of data.
@param requestCacheKey
the request cache key that data will b... | putInCache | 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 |
@SuppressWarnings("unchecked")
public <T> void putInCache(final Object requestCacheKey, final T data, RequestListener<T> listener) {
putInCache((Class<T>) data.getClass(), requestCacheKey, data, listener);
} | Adds some data to the cache, asynchronously. Same as
{@link #putInCache(Class, Object, Object, RequestListener)} where the
class used to identify the request is data.getClass().
@param requestCacheKey
the request cache key that data will be stored in.
@param data
the data to store. Maybe null if s... | putInCache | 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 |
@SuppressWarnings("unchecked")
public <T> void putInCache(final Object requestCacheKey, final T data) {
putInCache((Class<T>) data.getClass(), requestCacheKey, data);
} | Adds some data to the cache, asynchronously. Same as
{@link #putInCache(Class, Object, Object, RequestListener)} where the
class used to identify the request is data.getClass() and with a null
listener. Operation will take place but you won't be notified.
@param requestCacheKey
the request cache key that dat... | putInCache | 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> void cancel(final Class<T> clazz, final Object requestCacheKey) {
final SpiceRequest<T> request = new SpiceRequest<T>(clazz) {
@Override
public T loadDataFromNetwork() throws Exception {
return null;
}
};
final CachedSpiceRequest<T>... | Cancel a pending request if it exists. If no such request exists, this
method does nothing. If a request identified by clazz and requestCacheKey
exists, it will be cancelled and its associated listeners will get
notified. This method is asynchronous.
@param clazz
the class of the result of the pending reques... | cancel | 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 loadDataFromNetwork() throws Exception {
return null;
} | Cancel a pending request if it exists. If no such request exists, this
method does nothing. If a request identified by clazz and requestCacheKey
exists, it will be cancelled and its associated listeners will get
notified. This method is asynchronous.
@param clazz
the class of the result of the pending reques... | loadDataFromNetwork | 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 dontNotifyRequestListenersForRequest(final SpiceRequest<?> request) {
executorService.execute(new Runnable() {
@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 ... | dontNotifyRequestListenersForRequest | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.