1package com.bumptech.glide.load.model.stream; 2 3import com.bumptech.glide.load.data.ByteArrayFetcher; 4import com.bumptech.glide.load.data.DataFetcher; 5 6import java.io.InputStream; 7import java.util.UUID; 8 9/** 10 * A base class to convert byte arrays to input streams so they can be decoded. This class is abstract because there is 11 * no simple/quick way to generate an id from the bytes themselves, so subclass must include an id. 12 */ 13public class StreamByteArrayLoader implements StreamModelLoader<byte[]> { 14 private String id; 15 16 public StreamByteArrayLoader() { 17 this(UUID.randomUUID().toString()); 18 } 19 20 public StreamByteArrayLoader(String id) { 21 this.id = id; 22 } 23 24 @Override 25 public DataFetcher<InputStream> getResourceFetcher(byte[] model, int width, int height) { 26 return new ByteArrayFetcher(model, id); 27 } 28} 29