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 com.android.camera.BitmapManager; 20 21import android.content.ContentResolver; 22import android.graphics.Bitmap; 23import android.net.Uri; 24import android.provider.MediaStore.Images; 25import android.util.Log; 26 27/** 28 * Represents a particular video and provides access to the underlying data and 29 * two thumbnail bitmaps as well as other information such as the id, and the 30 * path to the actual video data. 31 */ 32public class VideoObject extends BaseImage implements IImage { 33 private static final String TAG = "VideoObject"; 34 /** 35 * Constructor. 36 * 37 * @param id the image id of the image 38 * @param cr the content resolver 39 */ 40 protected VideoObject(ContentResolver cr, 41 long id, Uri uri, long miniThumbMagic, 42 long dateTaken) { 43 super(cr, id, uri, miniThumbMagic, 44 dateTaken); 45 } 46 47 @Override 48 public boolean equals(Object other) { 49 if (other == null || !(other instanceof VideoObject)) return false; 50 return fullSizeImageUri().equals( 51 ((VideoObject) other).fullSizeImageUri()); 52 } 53 54 @Override 55 public int hashCode() { 56 return fullSizeImageUri().toString().hashCode(); 57 } 58 59 @Override 60 public Bitmap miniThumbBitmap() { 61 try { 62 long id = mId; 63 return BitmapManager.instance().getThumbnail(mContentResolver, 64 id, Images.Thumbnails.MICRO_KIND, null, true); 65 } catch (Throwable ex) { 66 Log.e(TAG, "miniThumbBitmap got exception", ex); 67 return null; 68 } 69 } 70 71 @Override 72 public String toString() { 73 return new StringBuilder("VideoObject").append(mId).toString(); 74 } 75} 76