RequestKey.java revision 25ad6f98516a7af1ca71cfa07fb503d46dc8a7f1
1/* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.bitmap; 18 19import android.content.res.AssetFileDescriptor; 20 21 22import java.io.IOException; 23import java.io.InputStream; 24 25/** 26 * The decode task uses this class to get input to decode. You must implement at least one of 27 * {@link #createFd()} or {@link #createInputStream()}. {@link DecodeTask} will prioritize 28 * {@link #createFd()} before falling back to {@link #createInputStream()}. 29 * <p> 30 * Objects of this type will also serve as cache keys to fetch cached data for {@link PooledCache}s, 31 * so they must implement {@link #equals(Object)} and {@link #hashCode()}. 32 * <p> 33 * Clients of this interface must also implement {@link #equals(Object)} and {@link #hashCode()} as 34 * this object will be used as a cache key. 35 */ 36 37public interface RequestKey { 38 /** 39 * Create an {@link AssetFileDescriptor} for a local file stored on the device. This method will 40 * be called first; if it returns null, {@link #createInputStream()} will be called. 41 */ 42 public AssetFileDescriptor createFd() throws IOException; 43 44 /** 45 * Create an {@link InputStream} for a file. This method will be called if {@link #createFd()} 46 * returns null. 47 */ 48 public InputStream createInputStream() throws IOException; 49 50 /** 51 * Return true if the image source may have be oriented in either portrait or landscape, and 52 * will need to be automatically re-oriented based on accompanying Exif metadata. 53 */ 54 public boolean hasOrientationExif() throws IOException; 55}