1package com.bumptech.glide.load.resource; 2 3import com.bumptech.glide.load.engine.Resource; 4 5/** 6 * Simple wrapper for an arbitrary object which helps to satisfy some of the glide engine's contracts. 7 * <b>Suggested usages only include resource object which don't have size and cannot be recycled/closed.</b> 8 * 9 * @param <T> type of the wrapped resource 10 */ 11// TODO: there isn't much point in caching these... 12public class SimpleResource<T> implements Resource<T> { 13 protected final T data; 14 15 public SimpleResource(T data) { 16 if (data == null) { 17 throw new NullPointerException("Data must not be null"); 18 } 19 this.data = data; 20 } 21 22 @Override 23 public final T get() { 24 return data; 25 } 26 27 @Override 28 public final int getSize() { 29 return 1; 30 } 31 32 @Override 33 public void recycle() { 34 // no op 35 } 36} 37