Exemple #1
0
  /**
   * Store image to the disk cache. If max allowed size is set image may be rescaled on disk.
   *
   * @throws IOException if error happens
   */
  public void storeToDisk() throws IOException {
    if (manager.isPresentOnDisk(url)) {
      return;
    }

    if (!hasAllowedSize()) {
      IoUtils.consumeStream(getRemoteInputStream(), manager.getBuffersPool());
      return;
    }

    ImageResult result = decodeStream(getRemoteInputStream(), true);
    if (result.getType() == ImageSourceType.NETWORK && result.getBitmap() != null) {
      // image was scaled
      writeBitmapToDisk(result.getBitmap());
    }
  }