All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bumptech.glide.load.resource.bytes.ByteBufferRewinder Maven / Gradle / Ivy

Go to download

A fast and efficient image loading library for Android focused on smooth scrolling.

There is a newer version: 5.0.0-rc01
Show newest version
package com.bumptech.glide.load.resource.bytes;

import com.bumptech.glide.load.data.DataRewinder;
import java.io.IOException;
import java.nio.ByteBuffer;

/**
 * Rewinds {@link java.nio.ByteBuffer}s.
 */
public class ByteBufferRewinder implements DataRewinder {
  private final ByteBuffer buffer;

  public ByteBufferRewinder(ByteBuffer buffer) {
    this.buffer = buffer;
  }

  @Override
  public ByteBuffer rewindAndGet() throws IOException {
    buffer.position(0);
    return buffer;
  }

  @Override
  public void cleanup() {
    // Do nothing.
  }

  /**
   * Factory for {@link com.bumptech.glide.load.resource.bytes.ByteBufferRewinder}.
   */
  public static class Factory implements DataRewinder.Factory {

    @Override
    public DataRewinder build(ByteBuffer data) {
      return new ByteBufferRewinder(data);
    }

    @Override
    public Class getDataClass() {
      return ByteBuffer.class;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy