Tabnine Logo
com.octo.android.robospice.persistence.binary
Code IndexAdd Tabnine to your IDE (free)

How to use com.octo.android.robospice.persistence.binary

Best Java code snippets using com.octo.android.robospice.persistence.binary (Showing top 5 results out of 315)

origin: com.octo.android.robospice/robospice-cache

  @Override
  public void run() {
    try {
      FileUtils.writeByteArrayToFile(getCacheFile(cacheKey), byteArray);
    } catch (IOException e) {
      Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
    }
  };
};
origin: com.octo.android.robospice/robospice-cache

@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);
  }
}
origin: com.octo.android.robospice/robospice-cache

@Override
public InputStream saveDataToCacheAndReturnData(InputStream data, final Object cacheKey) throws CacheSavingException {
  // special case for inputstream object : as it can be read only
  // once,
  // 0) we extract the content of the input stream as a byte[]
  // 1) we save it in file asynchronously if enabled
  // 2) the result will be a new InputStream on the byte[]
  final byte[] byteArray;
  try {
    byteArray = IOUtils.toByteArray(data);
    if (isAsyncSaveEnabled()) {
      Thread t = new Thread() {
        @Override
        public void run() {
          try {
            FileUtils.writeByteArrayToFile(getCacheFile(cacheKey), byteArray);
          } catch (IOException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          }
        };
      };
      t.start();
    } else {
      FileUtils.writeByteArrayToFile(getCacheFile(cacheKey), byteArray);
    }
    return new ByteArrayInputStream(byteArray);
  } catch (IOException e) {
    throw new CacheSavingException(e);
  }
}
origin: com.octo.android.robospice/robospice-sample

@Override
public CacheManager createCacheManager(Application application) {
  CacheManager cacheManager = new CacheManager();
  // init
  InFileStringObjectPersister inFileStringObjectPersister = new InFileStringObjectPersister(application);
  InFileInputStreamObjectPersister inFileInputStreamObjectPersister = new InFileInputStreamObjectPersister(application);
  JacksonObjectPersisterFactory inJSonFileObjectPersisterFactory = new JacksonObjectPersisterFactory(application);
  inFileStringObjectPersister.setAsyncSaveEnabled(true);
  inFileInputStreamObjectPersister.setAsyncSaveEnabled(true);
  inJSonFileObjectPersisterFactory.setAsyncSaveEnabled(true);
  cacheManager.addPersister(inFileStringObjectPersister);
  cacheManager.addPersister(inFileInputStreamObjectPersister);
  cacheManager.addPersister(inJSonFileObjectPersisterFactory);
  return cacheManager;
}
origin: com.octo.android.robospice/robospice-cache

@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);
  }
}
com.octo.android.robospice.persistence.binary

Most used classes

  • InFileInputStreamObjectPersister
  • InFileBigInputStreamObjectPersister
    Stores / retrieves data in file system. This ObjectPersister is optimized for memory. It will only u
  • InFileBitmapObjectPersister
    Stores and retrieves bitmaps to/from file system. Support custom android.graphics.BitmapFactory.Opti
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now