1/* 2 * Copyright (C) 2009 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.camera.gallery; 18 19import android.content.ContentResolver; 20import android.net.Uri; 21 22import java.util.HashMap; 23 24/** 25 * An implementation of interface <code>IImageList</code> which contains only 26 * one image. 27 */ 28public class SingleImageList implements IImageList { 29 30 @SuppressWarnings("unused") 31 private static final String TAG = "BaseImageList"; 32 33 private IImage mSingleImage; 34 private Uri mUri; 35 36 public SingleImageList(ContentResolver resolver, Uri uri) { 37 mUri = uri; 38 mSingleImage = new UriImage(this, resolver, uri); 39 } 40 41 public HashMap<String, String> getBucketIds() { 42 throw new UnsupportedOperationException(); 43 } 44 45 public int getCount() { 46 return 1; 47 } 48 49 public boolean isEmpty() { 50 return false; 51 } 52 53 public int getImageIndex(IImage image) { 54 return image == mSingleImage ? 0 : -1; 55 } 56 57 public IImage getImageAt(int i) { 58 return i == 0 ? mSingleImage : null; 59 } 60 61 public boolean removeImage(IImage image) { 62 return false; 63 } 64 65 public boolean removeImageAt(int index) { 66 return false; 67 } 68 69 public IImage getImageForUri(Uri uri) { 70 return uri.equals(mUri) ? mSingleImage : null; 71 } 72 73 public void close() { 74 mSingleImage = null; 75 mUri = null; 76 } 77} 78