package com.bumptech.glide.load.resource.gifbitmap; import android.graphics.Bitmap; import com.bumptech.glide.load.engine.Resource; import com.bumptech.glide.load.resource.gif.GifDrawable; /** * A wrapper that contains either an {@link android.graphics.Bitmap} resource or an * {@link com.bumptech.glide.load.resource.gif.GifDrawable} resource. */ public class GifBitmapWrapper { private final Resource gifResource; private final Resource bitmapResource; public GifBitmapWrapper(Resource bitmapResource, Resource gifResource) { if (bitmapResource != null && gifResource != null) { throw new IllegalArgumentException("Can only contain either a bitmap resource or a gif resource, not both"); } if (bitmapResource == null && gifResource == null) { throw new IllegalArgumentException("Must contain either a bitmap resource or a gif resource"); } this.bitmapResource = bitmapResource; this.gifResource = gifResource; } /** * Returns the size of the wrapped resource. */ public int getSize() { if (bitmapResource != null) { return bitmapResource.getSize(); } else { return gifResource.getSize(); } } /** * Returns the wrapped {@link android.graphics.Bitmap} resource if it exists, or null. */ public Resource getBitmapResource() { return bitmapResource; } /** * Returns the wrapped {@link com.bumptech.glide.load.resource.gif.GifDrawable} resource if it exists, or null. */ public Resource getGifResource() { return gifResource; } }