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
public void createOrUpdateCacheEntryInDatabase(CacheEntry cacheEntry) throws SQLException { if (cacheEntry != null) { Dao<CacheEntry, ?> dao = getDao(CacheEntry.class); dao.createOrUpdate(cacheEntry); } }
Helper class which creates/updates our database and provides the DAOs.
createOrUpdateCacheEntryInDatabase
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
public <T> List<T> queryForAllFromDatabase(Class<T> modelObjectClass) throws SQLException { List<T> allObjectsInTable = new ArrayList<T>(); Dao<T, ?> dao = getDao(modelObjectClass); allObjectsInTable.addAll(dao.queryForAll()); return allObjectsInTable; }
Helper class which creates/updates our database and provides the DAOs.
queryForAllFromDatabase
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
public <T, ID> T queryForIdFromDatabase(ID id, Class<T> modelObjectClass) throws SQLException { Dao<T, ID> dao = getDao(modelObjectClass); T result = dao.queryForId(id); return result; }
Helper class which creates/updates our database and provides the DAOs.
queryForIdFromDatabase
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
public CacheEntry queryCacheKeyForIdFromDatabase(String id) throws SQLException { Dao<CacheEntry, String> dao = getDao(CacheEntry.class); return dao.queryForId(id); }
Helper class which creates/updates our database and provides the DAOs.
queryCacheKeyForIdFromDatabase
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
public <T, ID> void deleteByIdFromDataBase(ID id, Class<T> modelObjectClass) throws SQLException { Dao<T, ID> dao = getDao(modelObjectClass); dao.deleteById(id); }
Helper class which creates/updates our database and provides the DAOs.
deleteByIdFromDataBase
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
public <T> void clearTableFromDataBase(Class<T> modelObjectClass) throws SQLException { try { clearTable(modelObjectClass); } catch (Exception ex) { Ln.d(ex, "An exception occurred when cleaning table"); } }
Helper class which creates/updates our database and provides the DAOs.
clearTableFromDataBase
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
private <T> void clearTable(Class<T> clazz) throws SQLException { for (Field field : clazz.getDeclaredFields()) { ForeignCollectionField annotation = field.getAnnotation(ForeignCollectionField.class); if (annotation != null) { ParameterizedType stringListType = (ParameterizedType) field.getGenericType(); Class<?> itemInListClass = (Class<?>) stringListType.getActualTypeArguments()[0]; clearTable(itemInListClass); } } TableUtils.dropTable(getConnectionSource(), clazz, true); TableUtils.createTableIfNotExists(getConnectionSource(), clazz); }
Helper class which creates/updates our database and provides the DAOs.
clearTable
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
public <T> void deleteFromDataBase(Collection<T> objectList, Class<T> modelObjectClass) throws SQLException { if (objectList != null && !objectList.isEmpty()) { Dao<T, ?> dao = getDao(modelObjectClass); dao.delete(objectList); } }
Helper class which creates/updates our database and provides the DAOs.
deleteFromDataBase
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
public <T> void createInDatabaseIfNotExist(T modelObject, Class<T> modelObjectClass) throws SQLException { if (modelObject != null) { Dao<T, ?> dao = getDao(modelObjectClass); dao.createIfNotExists(modelObject); } }
Helper class which creates/updates our database and provides the DAOs.
createInDatabaseIfNotExist
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
public <T> void deleteFromDataBase(T modelObject, Class<T> modelObjectClass) throws SQLException { if (modelObject != null) { Dao<T, ?> dao = getDao(modelObjectClass); dao.delete(modelObject); } }
Helper class which creates/updates our database and provides the DAOs.
deleteFromDataBase
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
public <T> void deleteFromDataBase(ForeignCollection<T> modelObjectCollection, Class<T> modelObjectClass) throws SQLException { if (modelObjectCollection != null) { Dao<T, ?> dao = getDao(modelObjectClass); dao.delete(modelObjectCollection); } }
Helper class which creates/updates our database and provides the DAOs.
deleteFromDataBase
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
public <T> long countOfAllObjectsOfTable(Class<T> modelObjectClass) throws SQLException { Dao<T, ?> dao = getDao(modelObjectClass); return dao.countOf(); }
Helper class which creates/updates our database and provides the DAOs.
countOfAllObjectsOfTable
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
public <T, FT> ForeignCollection<FT> getNewEmptyForeignCollection(String foreignKeyColumnName, Class<T> modelObjectClass, Class<FT> foreignObjectClass) throws SQLException { Dao<T, ?> dao = getDao(modelObjectClass); return dao.getEmptyForeignCollection(foreignKeyColumnName); }
Helper class which creates/updates our database and provides the DAOs.
getNewEmptyForeignCollection
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
@Override public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) { // override if needed }
Helper class which creates/updates our database and provides the DAOs.
onUpgrade
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
@Override public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) { // override if needed }
Helper class which creates/updates our database and provides the DAOs.
onCreate
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite/src/main/java/com/octo/android/robospice/persistence/ormlite/RoboSpiceDatabaseHelper.java
Apache-2.0
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("id=").append(id); sb.append(", ").append("string=").append(string); sb.append(", ").append("millis=").append(millis); SimpleDateFormat dateFormatter = new SimpleDateFormat( "MM/dd/yyyy HH:mm:ss.S"); sb.append(", ").append("date=").append(dateFormatter.format(date)); sb.append(", ").append("even=").append(even); return sb.toString(); }
A simple demonstration object we are creating and persisting to the database.
toString
java
stephanenicolas/robospice
extensions/robospice-ormlite-parent/robospice-ormlite-test/src/main/java/com/octo/android/robospice/ormlite/test/model/SimpleData.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ormlite-parent/robospice-ormlite-test/src/main/java/com/octo/android/robospice/ormlite/test/model/SimpleData.java
Apache-2.0
public Class<R> getRetrofitedInterfaceClass() { return retrofitedInterfaceClass; }
A simplified {@link SpiceRequest} that makes it even easier to use a retrofited REST service. @author SNI @param <T> the result type of this request. @param <R> the retrofited interface used by this request.
getRetrofitedInterfaceClass
java
stephanenicolas/robospice
extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/request/retrofit/RetrofitSpiceRequest.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/request/retrofit/RetrofitSpiceRequest.java
Apache-2.0
public void setService(R service) { this.service = service; }
A simplified {@link SpiceRequest} that makes it even easier to use a retrofited REST service. @author SNI @param <T> the result type of this request. @param <R> the retrofited interface used by this request.
setService
java
stephanenicolas/robospice
extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/request/retrofit/RetrofitSpiceRequest.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/request/retrofit/RetrofitSpiceRequest.java
Apache-2.0
public R getService() { return service; }
A simplified {@link SpiceRequest} that makes it even easier to use a retrofited REST service. @author SNI @param <T> the result type of this request. @param <R> the retrofited interface used by this request.
getService
java
stephanenicolas/robospice
extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/request/retrofit/RetrofitSpiceRequest.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/request/retrofit/RetrofitSpiceRequest.java
Apache-2.0
@Override public CacheManager createCacheManager(Application application) throws CacheCreationException { CacheManager cacheManager = new CacheManager(); cacheManager.addPersister(new GsonRetrofitObjectPersisterFactory(application, getConverter(), getCacheFolder())); return cacheManager; }
A pre-set, easy to use, retrofit service. It will use retrofit for network requests and both networking and caching will use Gson. To use it, just add to your manifest : <pre> &lt;service android:name="com.octo.android.robospice.retrofit.RetrofitGsonSpiceService" android:exported="false" /&gt; </pre> @author SNI
createCacheManager
java
stephanenicolas/robospice
extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/retrofit/RetrofitGsonSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/retrofit/RetrofitGsonSpiceService.java
Apache-2.0
@Override protected Converter createConverter() { return new GsonConverter(new Gson()); }
A pre-set, easy to use, retrofit service. It will use retrofit for network requests and both networking and caching will use Gson. To use it, just add to your manifest : <pre> &lt;service android:name="com.octo.android.robospice.retrofit.RetrofitGsonSpiceService" android:exported="false" /&gt; </pre> @author SNI
createConverter
java
stephanenicolas/robospice
extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/retrofit/RetrofitGsonSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/retrofit/RetrofitGsonSpiceService.java
Apache-2.0
public File getCacheFolder() { return null; }
A pre-set, easy to use, retrofit service. It will use retrofit for network requests and both networking and caching will use Gson. To use it, just add to your manifest : <pre> &lt;service android:name="com.octo.android.robospice.retrofit.RetrofitGsonSpiceService" android:exported="false" /&gt; </pre> @author SNI
getCacheFolder
java
stephanenicolas/robospice
extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/retrofit/RetrofitGsonSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/retrofit/RetrofitGsonSpiceService.java
Apache-2.0
@Override public CacheManager createCacheManager(Application application) throws CacheCreationException { CacheManager cacheManager = new CacheManager(); cacheManager.addPersister(new RetrofitObjectPersisterFactory(application, getConverter(), getCacheFolder())); return cacheManager; }
A pre-set, easy to use, retrofit service. It will use retrofit for network requests and both networking and caching will use Jackson. To use it, just add to your manifest : <pre> &lt;service android:name="com.octo.android.robospice.retrofit.RetrofitJacksonSpiceService" android:exported="false" /&gt; </pre> @author Vlad Shvaydetskiy
createCacheManager
java
stephanenicolas/robospice
extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/retrofit/RetrofitJackson2SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/retrofit/RetrofitJackson2SpiceService.java
Apache-2.0
@Override protected Converter createConverter() { return new JacksonConverter(new ObjectMapper()); }
A pre-set, easy to use, retrofit service. It will use retrofit for network requests and both networking and caching will use Jackson. To use it, just add to your manifest : <pre> &lt;service android:name="com.octo.android.robospice.retrofit.RetrofitJacksonSpiceService" android:exported="false" /&gt; </pre> @author Vlad Shvaydetskiy
createConverter
java
stephanenicolas/robospice
extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/retrofit/RetrofitJackson2SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/retrofit/RetrofitJackson2SpiceService.java
Apache-2.0
public File getCacheFolder() { return null; }
A pre-set, easy to use, retrofit service. It will use retrofit for network requests and both networking and caching will use Jackson. To use it, just add to your manifest : <pre> &lt;service android:name="com.octo.android.robospice.retrofit.RetrofitJacksonSpiceService" android:exported="false" /&gt; </pre> @author Vlad Shvaydetskiy
getCacheFolder
java
stephanenicolas/robospice
extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/retrofit/RetrofitJackson2SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-retrofit-parent/robospice-retrofit/src/main/java/com/octo/android/robospice/retrofit/RetrofitJackson2SpiceService.java
Apache-2.0
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("id=").append(id); sb.append(", ").append("string=").append(string); sb.append(", ").append("millis=").append(millis); SimpleDateFormat dateFormatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.S"); sb.append(", ").append("date=").append(dateFormatter.format(date)); sb.append(", ").append("even=").append(even); return sb.toString(); }
A simple demonstration object we are creating and persisting to the database.
toString
java
stephanenicolas/robospice
extensions/robospice-retrofit-parent/robospice-retrofit-test/src/main/java/com/octo/android/robospice/retrofit/test/model/SimpleData.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-retrofit-parent/robospice-retrofit-test/src/main/java/com/octo/android/robospice/retrofit/test/model/SimpleData.java
Apache-2.0
@Override public CacheManager createCacheManager(Application application) throws CacheCreationException { CacheManager cacheManager = new CacheManager(); cacheManager.addPersister(new GsonObjectPersisterFactory(application)); return cacheManager; }
A {@link SpringAndroidSpiceService} dedicated to json web services via gson. Provides caching. @author sni
createCacheManager
java
stephanenicolas/robospice
extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/GsonSpringAndroidSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/GsonSpringAndroidSpiceService.java
Apache-2.0
@Override public RestTemplate createRestTemplate() { RestTemplate restTemplate = new RestTemplate(); // web services support json responses GsonHttpMessageConverter jsonConverter = new GsonHttpMessageConverter(); final List<HttpMessageConverter<?>> listHttpMessageConverters = restTemplate.getMessageConverters(); listHttpMessageConverters.add(jsonConverter); restTemplate.setMessageConverters(listHttpMessageConverters); return restTemplate; }
A {@link SpringAndroidSpiceService} dedicated to json web services via gson. Provides caching. @author sni
createRestTemplate
java
stephanenicolas/robospice
extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/GsonSpringAndroidSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/GsonSpringAndroidSpiceService.java
Apache-2.0
@Override public CacheManager createCacheManager(Application application) throws CacheCreationException { CacheManager cacheManager = new CacheManager(); cacheManager.addPersister(new Jackson2ObjectPersisterFactory(application)); return cacheManager; }
A {@link SpringAndroidSpiceService} dedicated to json web services via Jackson. Provides caching. @author sni
createCacheManager
java
stephanenicolas/robospice
extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/Jackson2SpringAndroidSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/Jackson2SpringAndroidSpiceService.java
Apache-2.0
@Override public RestTemplate createRestTemplate() { RestTemplate restTemplate = new RestTemplate(); // web services support json responses MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter(); final List<HttpMessageConverter<?>> listHttpMessageConverters = restTemplate.getMessageConverters(); listHttpMessageConverters.add(jsonConverter); restTemplate.setMessageConverters(listHttpMessageConverters); return restTemplate; }
A {@link SpringAndroidSpiceService} dedicated to json web services via Jackson. Provides caching. @author sni
createRestTemplate
java
stephanenicolas/robospice
extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/Jackson2SpringAndroidSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/Jackson2SpringAndroidSpiceService.java
Apache-2.0
@Override public CacheManager createCacheManager(Application application) throws CacheCreationException { CacheManager cacheManager = new CacheManager(); cacheManager.addPersister(new JacksonObjectPersisterFactory(application)); return cacheManager; }
A {@link SpringAndroidSpiceService} dedicated to json web services via Jackson. Provides caching. @author sni
createCacheManager
java
stephanenicolas/robospice
extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/JacksonSpringAndroidSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/JacksonSpringAndroidSpiceService.java
Apache-2.0
@Override public RestTemplate createRestTemplate() { RestTemplate restTemplate = new RestTemplate(); // web services support json responses MappingJacksonHttpMessageConverter jsonConverter = new MappingJacksonHttpMessageConverter(); final List<HttpMessageConverter<?>> listHttpMessageConverters = restTemplate.getMessageConverters(); listHttpMessageConverters.add(jsonConverter); restTemplate.setMessageConverters(listHttpMessageConverters); return restTemplate; }
A {@link SpringAndroidSpiceService} dedicated to json web services via Jackson. Provides caching. @author sni
createRestTemplate
java
stephanenicolas/robospice
extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/JacksonSpringAndroidSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/JacksonSpringAndroidSpiceService.java
Apache-2.0
@Override public void onCreate() { super.onCreate(); restTemplate = createRestTemplate(); }
This class offers a {@link SpiceService} that injects a {@link RestTemplate} from spring android into every {@link SpringAndroidSpiceRequest} it has to execute. Developpers will have to implement {@link #createRestTemplate()} in addition to the usual {@link #createCacheManager(android.app.Application)} methods to create a {@link RestTemplate} and configure it. @author sni
onCreate
java
stephanenicolas/robospice
extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/SpringAndroidSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/SpringAndroidSpiceService.java
Apache-2.0
@Override public void addRequest(CachedSpiceRequest<?> request, Set<RequestListener<?>> listRequestListener) { if (request.getSpiceRequest() instanceof SpringAndroidSpiceRequest) { ((SpringAndroidSpiceRequest<?>) request.getSpiceRequest()).setRestTemplate(restTemplate); } super.addRequest(request, listRequestListener); }
This class offers a {@link SpiceService} that injects a {@link RestTemplate} from spring android into every {@link SpringAndroidSpiceRequest} it has to execute. Developpers will have to implement {@link #createRestTemplate()} in addition to the usual {@link #createCacheManager(android.app.Application)} methods to create a {@link RestTemplate} and configure it. @author sni
addRequest
java
stephanenicolas/robospice
extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/SpringAndroidSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/SpringAndroidSpiceService.java
Apache-2.0
@Override public CacheManager createCacheManager(Application application) throws CacheCreationException { CacheManager cacheManager = new CacheManager(); cacheManager.addPersister(new SimpleSerializerObjectPersisterFactory(application)); return cacheManager; }
A {@link SpringAndroidSpiceService} dedicated to xml web services. Provides caching. @author sni
createCacheManager
java
stephanenicolas/robospice
extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/XmlSpringAndroidSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/XmlSpringAndroidSpiceService.java
Apache-2.0
@Override public RestTemplate createRestTemplate() { RestTemplate restTemplate = new RestTemplate(); // web services support xml responses SimpleXmlHttpMessageConverter jsonConverter = new SimpleXmlHttpMessageConverter(); final List<HttpMessageConverter<?>> listHttpMessageConverters = restTemplate.getMessageConverters(); listHttpMessageConverters.add(jsonConverter); restTemplate.setMessageConverters(listHttpMessageConverters); return restTemplate; }
A {@link SpringAndroidSpiceService} dedicated to xml web services. Provides caching. @author sni
createRestTemplate
java
stephanenicolas/robospice
extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/XmlSpringAndroidSpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-spring-android-parent/robospice-spring-android/src/main/java/com/octo/android/robospice/XmlSpringAndroidSpiceService.java
Apache-2.0
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("id=").append(id); sb.append(", ").append("string=").append(string); sb.append(", ").append("millis=").append(millis); SimpleDateFormat dateFormatter = new SimpleDateFormat( "MM/dd/yyyy HH:mm:ss.S"); sb.append(", ").append("date=").append(dateFormatter.format(date)); sb.append(", ").append("even=").append(even); return sb.toString(); }
A simple demonstration object we are creating and persisting to the database.
toString
java
stephanenicolas/robospice
extensions/robospice-spring-android-parent/robospice-spring-android-test/src/main/java/com/octo/android/robospice/springandroid/test/model/json/SimpleData.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-spring-android-parent/robospice-spring-android-test/src/main/java/com/octo/android/robospice/springandroid/test/model/json/SimpleData.java
Apache-2.0
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("id=").append(id); sb.append(", ").append("string=").append(string); sb.append(", ").append("millis=").append(millis); SimpleDateFormat dateFormatter = new SimpleDateFormat( "MM/dd/yyyy HH:mm:ss.S"); sb.append(", ").append("date=").append(dateFormatter.format(date)); sb.append(", ").append("even=").append(even); return sb.toString(); }
A simple demonstration object we are creating and persisting to the database.
toString
java
stephanenicolas/robospice
extensions/robospice-spring-android-parent/robospice-spring-android-test/src/main/java/com/octo/android/robospice/springandroid/test/model/xml/SimpleData.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-spring-android-parent/robospice-spring-android-test/src/main/java/com/octo/android/robospice/springandroid/test/model/xml/SimpleData.java
Apache-2.0
protected final void updateListItemViewAsynchronously(final T data, final SpiceListItemView<T> spiceListItemView) { if (!registered(spiceListItemView)) { addSpiceListItemView(spiceListItemView); freshDrawableSet.add(data); } for (int imageIndex = 0; imageIndex < spiceListItemView.getImageViewCount(); imageIndex++) { imageWidth = Math.max(imageWidth, spiceListItemView.getImageView(imageIndex).getWidth()); imageHeight = Math.max(imageHeight, spiceListItemView.getImageView(imageIndex).getHeight()); performBitmapRequestAsync(spiceListItemView, data, imageIndex); } }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
updateListItemViewAsynchronously
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
@SuppressWarnings("unchecked") @Override public View getView(final int position, final View convertView, final ViewGroup parent) { SpiceListItemView<T> spiceListItemView; T currentItem = getItem(position); if (convertView != null) { spiceListItemView = (SpiceListItemView<T>) convertView; } else { spiceListItemView = createView(getContext(), parent); } spiceListItemView.update(currentItem); // this is the most important line. It will update views automatically // ---------------------------------------- updateListItemViewAsynchronously(currentItem, spiceListItemView); // ---------------------------------------- return (View) spiceListItemView; }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
getView
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
public final void performBitmapRequestAsync(final SpiceListItemView<T> spiceListItemView, final T data, final int imageIndex) { new ThumbnailAsynTask(createRequest(data, imageIndex, imageWidth, imageHeight)).execute(data, spiceListItemView, imageIndex); }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
performBitmapRequestAsync
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
private void addSpiceListItemView(final SpiceListItemView<T> spiceListItemView) { this.networkFetchingAuthorizationStateChangeListenerList.add(new NetworkFetchingAuthorizationStateChangeAdapter(spiceListItemView)); }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
addSpiceListItemView
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
private boolean registered(final SpiceListItemView<T> view) { for (NetworkFetchingAuthorizationStateChangeAdapter listener : networkFetchingAuthorizationStateChangeListenerList) { if (listener.getView() == view) { return true; } } return false; }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
registered
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
private void fireOnNetworkFetchingAllowedChange() { synchronized (networkFetchingAuthorizationStateChangeListenerList) { for (NetworkFetchingAuthorizationStateChangeAdapter networkFetchingAuthorizationStateChangeListener : networkFetchingAuthorizationStateChangeListenerList) { Ln.d("calling state change listener"); networkFetchingAuthorizationStateChangeListener.onNetworkFetchingAllowedChange(isNetworkFetchingAllowed); } } }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
fireOnNetworkFetchingAllowedChange
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
private void initialize(final Context context, final SpiceManager spiceManagerBinary) { this.spiceManagerBinary = spiceManagerBinary; defaultDrawable = context.getResources().getDrawable(android.R.drawable.picture_frame); }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
initialize
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
@Override public final void onRequestFailure(final SpiceException spiceException) { Ln.e(SpiceListItemView.class.getName(), "Unable to retrive image", spiceException); thumbImageView.setImageDrawable(defaultDrawable); }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
onRequestFailure
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
@Override public final void onRequestSuccess(final Bitmap bitmap) { freshDrawableSet.add(data); if (this.data.equals(spiceListItemView.getData())) { loadBitmapAsynchronously(data, thumbImageView, imageFileName); } }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
onRequestSuccess
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
protected void loadBitmapAsynchronously(final T octo, final ImageView thumbImageView, final String tempThumbnailImageFileName) { if (thumbImageView.getTag() != null && thumbImageView.getTag().equals(tempThumbnailImageFileName)) { return; } if (cancelPotentialWork(tempThumbnailImageFileName, thumbImageView)) { final BitmapWorkerTask task = new BitmapWorkerTask(thumbImageView, octo); task.fileName = tempThumbnailImageFileName; final AsyncDrawable asyncDrawable = new AsyncDrawable(getContext().getResources(), task); thumbImageView.setImageDrawable(asyncDrawable); thumbImageView.setTag(tempThumbnailImageFileName); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, tempThumbnailImageFileName); } else { task.execute(tempThumbnailImageFileName); } } }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
loadBitmapAsynchronously
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
private boolean cancelPotentialWork(final String fileName, final ImageView imageView) { final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView); if (bitmapWorkerTask != null) { final String bitmapFileName = bitmapWorkerTask.fileName; if (bitmapFileName == null || !bitmapFileName.equals(fileName)) { // Cancel previous task bitmapWorkerTask.cancel(true); } else { // The same work is already in progress return false; } } // No task associated with the ImageView, or an existing task was // cancelled return true; }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
cancelPotentialWork
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
protected final BitmapWorkerTask getBitmapWorkerTask(final ImageView imageView) { if (imageView != null) { final Drawable drawable = imageView.getDrawable(); if (drawable instanceof BaseSpiceArrayAdapter.AsyncDrawable) { @SuppressWarnings("unchecked") final AsyncDrawable asyncDrawable = (AsyncDrawable) drawable; return asyncDrawable.getBitmapWorkerTask(); } } return null; }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
getBitmapWorkerTask
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
@SuppressWarnings("unchecked") @Override protected final Boolean doInBackground(final Object... params) { data = (T) params[0]; spiceListItemView = (SpiceListItemView<T>) params[1]; imageIndex = (Integer) params[2]; if (bitmapRequest != null) { File tempThumbnailImageFile = bitmapRequest.getCacheFile(); tempThumbnailImageFileName = tempThumbnailImageFile.getAbsolutePath(); Ln.d("Filename : " + tempThumbnailImageFileName); if (!tempThumbnailImageFile.exists()) { if (isNetworkFetchingAllowed) { ImageRequestListener imageRequestListener = new ImageRequestListener(data, spiceListItemView, imageIndex, tempThumbnailImageFileName); spiceManagerBinary.execute((SpiceRequest<Bitmap>) bitmapRequest, "THUMB_IMAGE_" + data.hashCode(), DurationInMillis.ALWAYS_EXPIRED, imageRequestListener); } return false; } } return true; }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
doInBackground
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
@Override protected final void onPostExecute(final Boolean isImageAvailableInCache) { if (isImageAvailableInCache) { loadBitmapAsynchronously(data, spiceListItemView.getImageView(imageIndex), tempThumbnailImageFileName); } else { spiceListItemView.getImageView(imageIndex).setImageDrawable(defaultDrawable); } }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
onPostExecute
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
@Override protected Drawable doInBackground(final String... params) { fileName = params[0]; return new BitmapDrawable(getContext().getResources(), BitmapFactory.decodeFile(fileName, null)); }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
doInBackground
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
@Override protected void onPostExecute(Drawable drawable) { if (isCancelled()) { drawable = null; } if (imageViewReference != null && drawable != null) { final ImageView imageView = imageViewReference.get(); final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView); if (this == bitmapWorkerTask) { if (freshDrawableSet.remove(data)) { Drawable[] layers = new Drawable[] {defaultDrawable, drawable}; TransitionDrawable transitionDrawable = new TransitionDrawable(layers); transitionDrawable.setCrossFadeEnabled(true); transitionDrawable.startTransition(getContext().getResources().getInteger(android.R.integer.config_longAnimTime)); imageView.setImageDrawable(transitionDrawable); } else { imageView.setImageDrawable(drawable); } } } }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
onPostExecute
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
public void onNetworkFetchingAllowedChange(final boolean networkFetchingAllowed) { SpiceListItemView<T> spiceListItemView = weakReferenceSpiceListItemView.get(); if (spiceListItemView != null && networkFetchingAllowed) { T data = spiceListItemView.getData(); for (int imageIndex = 0; imageIndex < spiceListItemView.getImageViewCount(); imageIndex++) { performBitmapRequestAsync(spiceListItemView, data, imageIndex); } } }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
onNetworkFetchingAllowedChange
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
public SpiceListItemView<T> getView() { return weakReferenceSpiceListItemView.get(); }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
getView
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
public BitmapWorkerTask getBitmapWorkerTask() { return bitmapWorkerTaskReference.get(); }
Updates a {@link SpiceListItemView} containing some data. The method {@link #createRequest(Object)} will be applied to data to know which bitmapRequest to execute to get data from network if needed. This method must be called during {@link #getView(int, android.view.View, android.view.ViewGroup)}. @param data the data to update the {@link SpiceListItemView} with. @param spiceListItemView the {@link SpiceListItemView} that displays an image to represent data.
getBitmapWorkerTask
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/BaseSpiceArrayAdapter.java
Apache-2.0
@Override public void setOnScrollListener(OnScrollListener l) { onScrollListener.setWrappedListener(l); super.setOnScrollListener(onScrollListener); }
{@inheritDoc} @param l The listener to register with the ListView, or {@code null} to unregister an existing one.
setOnScrollListener
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java
Apache-2.0
@Override public void setAdapter(ListAdapter adapter) { if (!(adapter instanceof BaseSpiceArrayAdapter)) { throw new IllegalArgumentException("SpiceLists only support SpiceArrayAdapters."); } super.setAdapter(adapter); }
{@inheritDoc} @param l The listener to register with the ListView, or {@code null} to unregister an existing one.
setAdapter
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java
Apache-2.0
@Override public BaseSpiceArrayAdapter<?> getAdapter() { ListAdapter adapter = super.getAdapter(); if (adapter == null) { return null; } else if (adapter instanceof BaseSpiceArrayAdapter<?>) { return (BaseSpiceArrayAdapter<?>) adapter; } else { return (BaseSpiceArrayAdapter<?>) ((HeaderViewListAdapter) adapter).getWrappedAdapter(); } }
{@inheritDoc} @param l The listener to register with the ListView, or {@code null} to unregister an existing one.
getAdapter
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java
Apache-2.0
private void setWrappedListener(OnScrollListener l) { this.wrappedListener = l; }
{@inheritDoc} @param l The listener to register with the ListView, or {@code null} to unregister an existing one.
setWrappedListener
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java
Apache-2.0
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (getAdapter() != null) { getAdapter().setNetworkFetchingAllowed(scrollState == SCROLL_STATE_IDLE); } if (wrappedListener != null) { wrappedListener.onScrollStateChanged(view, scrollState); } }
{@inheritDoc} @param l The listener to register with the ListView, or {@code null} to unregister an existing one.
onScrollStateChanged
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java
Apache-2.0
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (wrappedListener != null) { wrappedListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount); } }
{@inheritDoc} @param l The listener to register with the ListView, or {@code null} to unregister an existing one.
onScroll
java
stephanenicolas/robospice
extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java
https://github.com/stephanenicolas/robospice/blob/master/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java
Apache-2.0
public Application getApplication() { return application; }
Super class of all entities responsible for loading/saving objects of a given class in the cache. @author sni @param <T> the class of the objects this {@link ObjectPersister} can persist/unpersist.
getApplication
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersister.java
Apache-2.0
public Class<T> getHandledClass() { return clazz; }
Super class of all entities responsible for loading/saving objects of a given class in the cache. @author sni @param <T> the class of the objects this {@link ObjectPersister} can persist/unpersist.
getHandledClass
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersister.java
Apache-2.0
@Override public boolean canHandleClass(Class<?> clazz) { return clazz.equals(this.clazz); }
Super class of all entities responsible for loading/saving objects of a given class in the cache. @author sni @param <T> the class of the objects this {@link ObjectPersister} can persist/unpersist.
canHandleClass
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersister.java
Apache-2.0
public boolean isAsyncSaveEnabled() { return isAsyncSaveEnabled; }
Return the creation date of creation of cache. entry for a given cacheKey. @param cacheKey the cachekey identifying the object to look for. @return a long corresponding to the creation date of creation of cache. @throws CacheLoadingException if there is no such element in cache.
isAsyncSaveEnabled
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersister.java
Apache-2.0
public void setAsyncSaveEnabled(boolean isAsyncSaveEnabled) { this.isAsyncSaveEnabled = isAsyncSaveEnabled; }
Return the creation date of creation of cache. entry for a given cacheKey. @param cacheKey the cachekey identifying the object to look for. @return a long corresponding to the creation date of creation of cache. @throws CacheLoadingException if there is no such element in cache.
setAsyncSaveEnabled
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersister.java
Apache-2.0
protected final Application getApplication() { return mApplication; }
Creates an {@link ObjectPersisterFactory} given an Android application and a list of handled classes. @param application the android context needed to access android file system or databases to store. @param listHandledClasses the list of classes that is handled by the factory. The factory will try to produce an {@link ObjectPersister} for each element of the list.
getApplication
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersisterFactory.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersisterFactory.java
Apache-2.0
@Override public boolean canHandleClass(Class<?> clazz) { if (listHandledClasses == null) { return true; } else { return listHandledClasses.contains(clazz); } }
Wether or not this bus element can persist/unpersist objects of the given class clazz. @param clazz the class of objets we are looking forward to persist. @return true if this bus element can persist/unpersist objects of the given class clazz. False otherwise.
canHandleClass
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersisterFactory.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersisterFactory.java
Apache-2.0
public void setAsyncSaveEnabled(boolean isAsyncSaveEnabled) { this.isAsyncSaveEnabled = isAsyncSaveEnabled; }
Set whether this {@link ObjectPersisterFactory} will set the {@link ObjectPersister} instances it produces to save data asynchronously or not. @param isAsyncSaveEnabled whether or not data will be saved asynchronously by {@link ObjectPersister} instances produced by this factory.
setAsyncSaveEnabled
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersisterFactory.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersisterFactory.java
Apache-2.0
public boolean isAsyncSaveEnabled() { return isAsyncSaveEnabled; }
Indicates whether this {@link ObjectPersisterFactory} will set the {@link ObjectPersister} instances it produces to save data asynchronously or not. @return true if the {@link ObjectPersister} instances it produces to save data asynchronously. False otherwise.
isAsyncSaveEnabled
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersisterFactory.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersisterFactory.java
Apache-2.0
protected List<Class<?>> getListHandledClasses() { return listHandledClasses; }
Return the list of classes persisted by this factory. @return the list of classes persisted by this factory.
getListHandledClasses
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersisterFactory.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/ObjectPersisterFactory.java
Apache-2.0
@Override public InputStream saveDataToCacheAndReturnData(InputStream data, Object cacheKey) throws CacheSavingException { FileOutputStream output = null; // special case for big inputstream object : as it can be read // only once and is too big to be locally // duplicated, // 1) we save it in file // 2) we load and return it from the file try { output = new FileOutputStream(getCacheFile(cacheKey)); IOUtils.copy(data, output); return new FileInputStream(getCacheFile(cacheKey)); } catch (IOException e) { throw new CacheSavingException(e); } finally { IOUtils.closeQuietly(output); } }
Stores / retrieves data in file system. This {@link ObjectPersister} is optimized for memory. It will only use file system to save the data, without allocating large memory space to transfert a given binary to the cache. It should be preferred to {@link InFileInputStreamObjectPersister} for low memory devices or memory intensive usages. @author SNI
saveDataToCacheAndReturnData
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBigInputStreamObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBigInputStreamObjectPersister.java
Apache-2.0
@Override public void setAsyncSaveEnabled(boolean isAsyncSaveEnabled) { if (isAsyncSaveEnabled) { throw new IllegalStateException("Asynchronous saving operation not supported."); } }
Stores / retrieves data in file system. This {@link ObjectPersister} is optimized for memory. It will only use file system to save the data, without allocating large memory space to transfert a given binary to the cache. It should be preferred to {@link InFileInputStreamObjectPersister} for low memory devices or memory intensive usages. @author SNI
setAsyncSaveEnabled
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBigInputStreamObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBigInputStreamObjectPersister.java
Apache-2.0
@Override protected Bitmap readCacheDataFromFile(File file) throws CacheLoadingException { Bitmap data; FileInputStream is = null; try { is = new FileInputStream(file.getAbsolutePath()); data = BitmapFactory.decodeStream(is, null, decodingOptions); } catch (Throwable ex) { throw new CacheLoadingException(String.format("Found the file %s but could not decode bitmap.", file.getAbsolutePath()), ex); } finally { if (is != null) { IOUtils.closeQuietly(is); } } if (data == null) { throw new CacheLoadingException(String.format("Found the file %s but could not decode bitmap.", file.getAbsolutePath())); } return data; }
Stores and retrieves bitmaps to/from file system. Support custom {@link android.graphics.BitmapFactory.Options} to lower disk usage. @author David Stemmer
readCacheDataFromFile
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
Apache-2.0
@Override public Bitmap saveDataToCacheAndReturnData(Bitmap data, Object cacheKey) throws CacheSavingException { BufferedOutputStream out = null; try { File cacheFile = getCacheFile(cacheKey); out = new BufferedOutputStream(new FileOutputStream(cacheFile)); boolean didCompress = data.compress(compressFormat, quality, out); if (!didCompress) { throw new CacheSavingException(String.format("Could not compress bitmap for path: %s", getCacheFile(cacheKey).getAbsolutePath())); } return data; } catch (IOException e) { throw new CacheSavingException(e); } finally { IOUtils.closeQuietly(out); } }
Stores and retrieves bitmaps to/from file system. Support custom {@link android.graphics.BitmapFactory.Options} to lower disk usage. @author David Stemmer
saveDataToCacheAndReturnData
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
Apache-2.0
public BitmapFactory.Options getDecodingOptions() { return decodingOptions; }
Stores and retrieves bitmaps to/from file system. Support custom {@link android.graphics.BitmapFactory.Options} to lower disk usage. @author David Stemmer
getDecodingOptions
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
Apache-2.0
public void setDecodingOptions(BitmapFactory.Options decodingOptions) { this.decodingOptions = decodingOptions; }
Stores and retrieves bitmaps to/from file system. Support custom {@link android.graphics.BitmapFactory.Options} to lower disk usage. @author David Stemmer
setDecodingOptions
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
Apache-2.0
public Bitmap.CompressFormat getCompressFormat() { return compressFormat; }
Stores and retrieves bitmaps to/from file system. Support custom {@link android.graphics.BitmapFactory.Options} to lower disk usage. @author David Stemmer
getCompressFormat
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
Apache-2.0
public void setCompressFormat(Bitmap.CompressFormat compressFormat) { this.compressFormat = compressFormat; }
Stores and retrieves bitmaps to/from file system. Support custom {@link android.graphics.BitmapFactory.Options} to lower disk usage. @author David Stemmer
setCompressFormat
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
Apache-2.0
public int getQuality() { return quality; }
Stores and retrieves bitmaps to/from file system. Support custom {@link android.graphics.BitmapFactory.Options} to lower disk usage. @author David Stemmer
getQuality
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
Apache-2.0
public void setQuality(int quality) { this.quality = quality; }
Stores and retrieves bitmaps to/from file system. Support custom {@link android.graphics.BitmapFactory.Options} to lower disk usage. @author David Stemmer
setQuality
java
stephanenicolas/robospice
robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-cache-parent/robospice-cache/src/main/java/com/octo/android/robospice/persistence/binary/InFileBitmapObjectPersister.java
Apache-2.0
public void setCacheFolder(File cacheFolder) throws CacheCreationException { if (cacheFolder == null) { cacheFolder = new File(getApplication().getCacheDir(), DEFAULT_ROOT_CACHE_DIR); } synchronized (cacheFolder.getAbsolutePath().intern()) { if (!cacheFolder.exists() && !cacheFolder.mkdirs()) { throw new CacheCreationException("The cache folder " + cacheFolder.getAbsolutePath() + " could not be created."); } } this.cacheFolder = cacheFolder; }
Set the cacheFolder to use. @param cacheFolder the new cache folder to use. Can be null, will then default to {@link #DEFAULT_ROOT_CACHE_DIR} sub folder in the application cache dir. @throws CacheCreationException if the cache folder doesn't exist or can't be created.
setCacheFolder
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 final File getCacheFolder() { return cacheFolder; }
Set the cacheFolder to use. @param cacheFolder the new cache folder to use. Can be null, will then default to {@link #DEFAULT_ROOT_CACHE_DIR} sub folder in the application cache dir. @throws CacheCreationException if the cache folder doesn't exist or can't be created.
getCacheFolder
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
@Override public long getCreationDateInCache(Object cacheKey) throws CacheLoadingException { File cacheFile = getCacheFile(cacheKey); if (cacheFile.exists()) { return cacheFile.lastModified(); } else { throw new CacheLoadingException( "Data could not be found in cache for cacheKey=" + cacheKey); } }
Set the cacheFolder to use. @param cacheFolder the new cache folder to use. Can be null, will then default to {@link #DEFAULT_ROOT_CACHE_DIR} sub folder in the application cache dir. @throws CacheCreationException if the cache folder doesn't exist or can't be created.
getCreationDateInCache
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
@Override public List<Object> getAllCacheKeys() { final String prefix = getCachePrefix(); int prefixLength = prefix.length(); String[] cacheFileNameList = getCacheFolder().list(new FilenameFilter() { @Override public boolean accept(File dir, String filename) { // patch from florianmski return filename.startsWith(prefix); } }); if (cacheFileNameList == null) { return Collections.emptyList(); } List<Object> result = new ArrayList<Object>(cacheFileNameList.length); for (String cacheFileName : cacheFileNameList) { String cacheKey = cacheFileName.substring(prefixLength); result.add(fromKey(cacheKey)); } return result; }
Set the cacheFolder to use. @param cacheFolder the new cache folder to use. Can be null, will then default to {@link #DEFAULT_ROOT_CACHE_DIR} sub folder in the application cache dir. @throws CacheCreationException if the cache folder doesn't exist or can't be created.
getAllCacheKeys
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
@Override public boolean accept(File dir, String filename) { // patch from florianmski return filename.startsWith(prefix); }
Set the cacheFolder to use. @param cacheFolder the new cache folder to use. Can be null, will then default to {@link #DEFAULT_ROOT_CACHE_DIR} sub folder in the application cache dir. @throws CacheCreationException if the cache folder doesn't exist or can't be created.
accept
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
@Override public List<T> loadAllDataFromCache() throws CacheLoadingException { List<Object> allCacheKeys = getAllCacheKeys(); List<T> result = new ArrayList<T>(allCacheKeys.size()); for (Object key : allCacheKeys) { result.add(loadDataFromCache(key, DurationInMillis.ALWAYS_RETURNED)); } return result; }
Set the cacheFolder to use. @param cacheFolder the new cache folder to use. Can be null, will then default to {@link #DEFAULT_ROOT_CACHE_DIR} sub folder in the application cache dir. @throws CacheCreationException if the cache folder doesn't exist or can't be created.
loadAllDataFromCache
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
@Override public boolean removeDataFromCache(Object cacheKey) { return getCacheFile(cacheKey).delete(); }
Set the cacheFolder to use. @param cacheFolder the new cache folder to use. Can be null, will then default to {@link #DEFAULT_ROOT_CACHE_DIR} sub folder in the application cache dir. @throws CacheCreationException if the cache folder doesn't exist or can't be created.
removeDataFromCache
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
@Override public void removeAllDataFromCache() { File cacheFolder = getCacheFolder(); File[] cacheFileList = cacheFolder.listFiles(new FileFilter() { @Override public boolean accept(File file) { return file.getName().startsWith(getCachePrefix()); } }); boolean allDeleted = true; for (File cacheFile : cacheFileList) { allDeleted = cacheFile.delete() && allDeleted; } if (allDeleted || cacheFileList.length == 0) { Ln.d("Some file could not be deleted from cache."); } }
Set the cacheFolder to use. @param cacheFolder the new cache folder to use. Can be null, will then default to {@link #DEFAULT_ROOT_CACHE_DIR} sub folder in the application cache dir. @throws CacheCreationException if the cache folder doesn't exist or can't be created.
removeAllDataFromCache
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
@Override public boolean accept(File file) { return file.getName().startsWith(getCachePrefix()); }
Set the cacheFolder to use. @param cacheFolder the new cache folder to use. Can be null, will then default to {@link #DEFAULT_ROOT_CACHE_DIR} sub folder in the application cache dir. @throws CacheCreationException if the cache folder doesn't exist or can't be created.
accept
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
@Override public T loadDataFromCache(Object cacheKey, long maxTimeInCache) throws CacheLoadingException { File file = getCacheFile(cacheKey); if (isCachedAndNotExpired(file, maxTimeInCache)) { return readCacheDataFromFile(file); } return null; }
Set the cacheFolder to use. @param cacheFolder the new cache folder to use. Can be null, will then default to {@link #DEFAULT_ROOT_CACHE_DIR} sub folder in the application cache dir. @throws CacheCreationException if the cache folder doesn't exist or can't be created.
loadDataFromCache
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
@Override public boolean isDataInCache(Object cacheKey, long maxTimeInCacheBeforeExpiry) { File file = getCacheFile(cacheKey); return isCachedAndNotExpired(file, maxTimeInCacheBeforeExpiry); }
Set the cacheFolder to use. @param cacheFolder the new cache folder to use. Can be null, will then default to {@link #DEFAULT_ROOT_CACHE_DIR} sub folder in the application cache dir. @throws CacheCreationException if the cache folder doesn't exist or can't be created.
isDataInCache
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 boolean isUsingKeySanitizer() { return keySanitizer != null; }
@return Whether or not this {@link InFileObjectPersister} uses a {@link KeySanitizer}.
isUsingKeySanitizer
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 setKeySanitizer(KeySanitizer keySanitizer) { this.keySanitizer = keySanitizer; }
@param keySanitizer the new key sanitizer to be used by this {@link InFileObjectPersister}. May be null, in that case no key sanitation will be used default). If key sanitation fails on a given cache key (by throwing a {@link KeySanitationExcepion}, original (unsanitized) cache keys will be used directly.
setKeySanitizer
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 KeySanitizer getKeySanitizer() { return keySanitizer; }
@return the key sanitizer used by this {@link InFileObjectPersister}. May be null, in that case no key sanitation will be used default).
getKeySanitizer
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 final File getCacheFile(Object cacheKey) { return new File(getCacheFolder(), getCachePrefix() + toKey(cacheKey.toString())); }
@return the key sanitizer used by this {@link InFileObjectPersister}. May be null, in that case no key sanitation will be used default).
getCacheFile
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
void setFactoryCachePrefix(String factoryCachePrefix) { this.factoryCachePrefix = factoryCachePrefix; }
@return the key sanitizer used by this {@link InFileObjectPersister}. May be null, in that case no key sanitation will be used default).
setFactoryCachePrefix
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 toKey(String cacheKey) { if (isUsingKeySanitizer()) { try { return (String) keySanitizer.sanitizeKey(cacheKey); } catch (KeySanitationExcepion e) { Ln.e(e, "Key could not be sanitized, falling back on original key."); return cacheKey; } } else { return cacheKey; } }
Get a key that may be sanitized if a {@link KeySanitizer} is used. @param cacheKey a non-sanitized cacheKey. @return a key that will be sanitized if a {@link KeySanitizer} is used.
toKey
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