Created
January 10, 2015 02:23
-
-
Save kamikat/107c0558538485e7c529 to your computer and use it in GitHub Desktop.
Object persister by-pass the cache file object to do tricks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.app.Application; | |
| import com.octo.android.robospice.persistence.exception.CacheCreationException; | |
| import com.octo.android.robospice.persistence.exception.CacheLoadingException; | |
| import com.octo.android.robospice.persistence.exception.CacheSavingException; | |
| import com.octo.android.robospice.persistence.file.InFileObjectPersister; | |
| import java.io.File; | |
| public class ByPassInFileObjectPersister extends InFileObjectPersister<File> { | |
| public ByPassInFileObjectPersister(Application application) throws CacheCreationException { | |
| super(application, File.class); | |
| } | |
| public ByPassInFileObjectPersister(Application application, File cacheFolder) throws CacheCreationException { | |
| super(application, File.class); | |
| } | |
| @Override | |
| protected File readCacheDataFromFile(File file) throws CacheLoadingException { | |
| return file; | |
| } | |
| @Override | |
| public File saveDataToCacheAndReturnData(File data, Object cacheKey) throws CacheSavingException { | |
| return data; | |
| } | |
| @Override | |
| public boolean isDataInCache(Object cacheKey, long maxTimeInCacheBeforeExpiry) { | |
| return super.isDataInCache(cacheKey, maxTimeInCacheBeforeExpiry); | |
| } | |
| @Override | |
| protected boolean isCachedAndNotExpired(File cacheFile, long maxTimeInCacheBeforeExpiry) { | |
| return true; | |
| } | |
| @Override | |
| protected boolean isCachedAndNotExpired(Object cacheKey, long maxTimeInCacheBeforeExpiry) { | |
| return true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment