Skip to content

Instantly share code, notes, and snippets.

@kamikat
Created January 10, 2015 02:23
Show Gist options
  • Select an option

  • Save kamikat/107c0558538485e7c529 to your computer and use it in GitHub Desktop.

Select an option

Save kamikat/107c0558538485e7c529 to your computer and use it in GitHub Desktop.
Object persister by-pass the cache file object to do tricks
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