diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-04-15 23:41:17 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-04-15 23:41:17 -0700 |
commit | 2094670d60f1d8feb70e0e1b7dd70d130ec89886 (patch) | |
tree | 450e9c755ca3f9c139b29d77a401f0bf8c2ea02c /src | |
parent | 0f56ef5704b7f1a0874528367147487c051876d9 (diff) | |
parent | 1e48aaec1c8bc82fac130698a7fbbba827abf2c7 (diff) | |
download | LegacyCamera-2094670d60f1d8feb70e0e1b7dd70d130ec89886.zip LegacyCamera-2094670d60f1d8feb70e0e1b7dd70d130ec89886.tar.gz LegacyCamera-2094670d60f1d8feb70e0e1b7dd70d130ec89886.tar.bz2 |
Merge change 208 into donut
* changes:
Code clean up.
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/android/camera/ImageManager.java | 35 | ||||
-rw-r--r-- | src/com/android/camera/gallery/BaseImageList.java | 92 | ||||
-rw-r--r-- | src/com/android/camera/gallery/DrmImageList.java | 18 | ||||
-rw-r--r-- | src/com/android/camera/gallery/IImageList.java | 2 | ||||
-rw-r--r-- | src/com/android/camera/gallery/Image.java | 16 | ||||
-rw-r--r-- | src/com/android/camera/gallery/ImageList.java | 66 | ||||
-rw-r--r-- | src/com/android/camera/gallery/SingleImageList.java | 24 | ||||
-rw-r--r-- | src/com/android/camera/gallery/VideoList.java | 69 | ||||
-rw-r--r-- | src/com/android/camera/gallery/VideoObject.java | 50 |
9 files changed, 123 insertions, 249 deletions
diff --git a/src/com/android/camera/ImageManager.java b/src/com/android/camera/ImageManager.java index 4b71494..4696e75 100755 --- a/src/com/android/camera/ImageManager.java +++ b/src/com/android/camera/ImageManager.java @@ -59,13 +59,14 @@ public class ImageManager { private static final String TAG = "ImageManager"; private static ImageManager sInstance = null; - private static Uri sStorageURI = Images.Media.EXTERNAL_CONTENT_URI; - private static Uri sThumbURI = Images.Thumbnails.EXTERNAL_CONTENT_URI; + private static final Uri STORAGE_URI = Images.Media.EXTERNAL_CONTENT_URI; + private static final Uri THUMB_URI + = Images.Thumbnails.EXTERNAL_CONTENT_URI; - private static Uri sVideoStorageURI = + private static final Uri VIDEO_STORAGE_URI = Uri.parse("content://media/external/video/media"); - private static Uri sVideoThumbURI = + private static final Uri VIDEO_THUMBNAIL_URI = Uri.parse("content://media/external/video/thumbnails"); /** @@ -228,7 +229,7 @@ public class ImageManager { values.put(Images.Media.DATA, value); } - return cr.insert(sStorageURI, values); + return cr.insert(STORAGE_URI, values); } private static class AddImageCancelable extends BaseCancelable<Void> { @@ -270,8 +271,8 @@ public class ImageManager { } long id = ContentUris.parseId(mUri); - BaseImageList il = new ImageList(mCtx, mCr, sStorageURI, - sThumbURI, SORT_ASCENDING, null); + BaseImageList il = new ImageList(mCr, STORAGE_URI, + THUMB_URI, SORT_ASCENDING, null); Image image = new Image(id, 0, mCr, il, il.getCount(), 0); String[] projection = new String[] { ImageColumns._ID, @@ -411,8 +412,8 @@ public class ImageManager { try { if (specificImageUri.getScheme() .equalsIgnoreCase("content")) { - l.add(new ImageList(ctx, cr, specificImageUri, - sThumbURI, sort, bucketId)); + l.add(new ImageList(cr, specificImageUri, + THUMB_URI, sort, bucketId)); } else { l.add(new SingleImageList(cr, specificImageUri)); } @@ -423,16 +424,16 @@ public class ImageManager { if (haveSdCard && location != DataLocation.INTERNAL) { if ((inclusion & INCLUDE_IMAGES) != 0) { try { - l.add(new ImageList(ctx, cr, sStorageURI, - sThumbURI, sort, bucketId)); + l.add(new ImageList(cr, STORAGE_URI, + THUMB_URI, sort, bucketId)); } catch (UnsupportedOperationException ex) { // ignore exception } } if ((inclusion & INCLUDE_VIDEOS) != 0) { try { - l.add(new VideoList(ctx, cr, sVideoStorageURI, - sVideoThumbURI, sort, bucketId)); + l.add(new VideoList(cr, VIDEO_STORAGE_URI, + VIDEO_THUMBNAIL_URI, sort, bucketId)); } catch (UnsupportedOperationException ex) { // ignore exception } @@ -442,7 +443,7 @@ public class ImageManager { || location == DataLocation.ALL) { if ((inclusion & INCLUDE_IMAGES) != 0) { try { - l.add(new ImageList(ctx, cr, + l.add(new ImageList(cr, Images.Media.INTERNAL_CONTENT_URI, Images.Thumbnails.INTERNAL_CONTENT_URI, sort, bucketId)); @@ -452,7 +453,7 @@ public class ImageManager { } if ((inclusion & INCLUDE_DRM_IMAGES) != 0) { try { - l.add(new DrmImageList(ctx, cr, + l.add(new DrmImageList(cr, DrmStore.Images.CONTENT_URI, sort, bucketId)); } catch (UnsupportedOperationException ex) { @@ -467,9 +468,9 @@ public class ImageManager { } else { if (haveSdCard && location != DataLocation.INTERNAL) { return new ImageList( - ctx, cr, sStorageURI, sThumbURI, sort, bucketId); + cr, STORAGE_URI, THUMB_URI, sort, bucketId); } else { - return new ImageList(ctx, cr, + return new ImageList(cr, Images.Media.INTERNAL_CONTENT_URI, Images.Thumbnails.INTERNAL_CONTENT_URI, sort, bucketId); diff --git a/src/com/android/camera/gallery/BaseImageList.java b/src/com/android/camera/gallery/BaseImageList.java index 6997a70..2d9daa8 100644 --- a/src/com/android/camera/gallery/BaseImageList.java +++ b/src/com/android/camera/gallery/BaseImageList.java @@ -24,12 +24,10 @@ import com.android.camera.Util; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; -import android.content.Context; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; -import android.os.ParcelFileDescriptor; import android.provider.BaseColumns; import android.provider.MediaStore.Images; import android.provider.MediaStore.Images.ImageColumns; @@ -56,43 +54,8 @@ public abstract class BaseImageList implements IImageList { private static final String WHERE_CLAUSE = "(" + Images.Media.MIME_TYPE + " in (?, ?, ?))"; - static final String[] IMAGE_PROJECTION = new String[] { - BaseColumns._ID, - MediaColumns.DATA, - ImageColumns.DATE_TAKEN, - ImageColumns.MINI_THUMB_MAGIC, - ImageColumns.ORIENTATION, - ImageColumns.MIME_TYPE}; - - static final String[] THUMB_PROJECTION = new String[] { - BaseColumns._ID, - Images.Thumbnails.IMAGE_ID, - Images.Thumbnails.WIDTH, - Images.Thumbnails.HEIGHT}; - - static final int INDEX_ID = Util.indexOf(IMAGE_PROJECTION, BaseColumns._ID); - static final int INDEX_DATA = - Util.indexOf(IMAGE_PROJECTION, MediaColumns.DATA); - static final int INDEX_MIME_TYPE = - Util.indexOf(IMAGE_PROJECTION, MediaColumns.MIME_TYPE); - static final int INDEX_DATE_TAKEN = - Util.indexOf(IMAGE_PROJECTION, ImageColumns.DATE_TAKEN); - static final int INDEX_MINI_THUMB_MAGIC = - Util.indexOf(IMAGE_PROJECTION, ImageColumns.MINI_THUMB_MAGIC); - static final int INDEX_ORIENTATION = - Util.indexOf(IMAGE_PROJECTION, ImageColumns.ORIENTATION); - static final int INDEX_THUMB_ID = - Util.indexOf(THUMB_PROJECTION, BaseColumns._ID); - static final int INDEX_THUMB_IMAGE_ID = - Util.indexOf(THUMB_PROJECTION, Images.Thumbnails.IMAGE_ID); - static final int INDEX_THUMB_WIDTH = - Util.indexOf(THUMB_PROJECTION, Images.Thumbnails.WIDTH); - static final int INDEX_THUMB_HEIGHT = - Util.indexOf(THUMB_PROJECTION, Images.Thumbnails.HEIGHT); - protected static final String[] ACCEPTABLE_IMAGE_TYPES = new String[] { "image/jpeg", "image/png", "image/gif" }; - protected static final String MINITHUMB_IS_NULL = "mini_thumb_magic isnull"; protected ContentResolver mContentResolver; protected int mSort; @@ -100,17 +63,13 @@ public abstract class BaseImageList implements IImageList { protected Cursor mCursor; protected boolean mCursorDeactivated; protected String mBucketId; - protected Context mContext; - protected Uri mUri; protected HashMap<Long, IImage> mCache = new HashMap<Long, IImage>(); protected MiniThumbFile mMiniThumbFile; protected Uri mThumbUri; - public BaseImageList(Context ctx, ContentResolver cr, Uri uri, int sort, + public BaseImageList(ContentResolver cr, Uri uri, int sort, String bucketId) { - mContext = ctx; mSort = sort; - mUri = uri; mBaseUri = uri; mBucketId = bucketId; mContentResolver = cr; @@ -161,6 +120,10 @@ public abstract class BaseImageList implements IImageList { } } + private static final String[] THUMB_PROJECTION = new String[] { + BaseColumns._ID + }; + private Uri getThumbnailUri(long imageId, int width, int height) { // we do not store thumbnails for DRM'd images if (mThumbUri == null) { @@ -168,6 +131,7 @@ public abstract class BaseImageList implements IImageList { } Uri uri = null; + Cursor c = mContentResolver.query(mThumbUri, THUMB_PROJECTION, Thumbnails.IMAGE_ID + "=?", new String[]{String.valueOf(imageId)}, null); @@ -177,7 +141,7 @@ public abstract class BaseImageList implements IImageList { // image id, then just update that row rather than creating a // new row. uri = ContentUris.withAppendedId( - mThumbUri, c.getLong(indexThumbId())); + mThumbUri, c.getLong(0)); c.commitUpdates(); } } finally { @@ -243,13 +207,12 @@ public abstract class BaseImageList implements IImageList { private Bitmap createThumbnailFromUri(Cursor c, long id) { Uri uri = ContentUris.withAppendedId(mBaseUri, id); Bitmap bitmap = Util.makeBitmap(THUMBNAIL_TARGET_SIZE, uri, - mContentResolver, null, null); + mContentResolver); if (bitmap != null) { storeThumbnail(bitmap, id); } else { - uri = ContentUris.withAppendedId(mBaseUri, id); bitmap = Util.makeBitmap(MINI_THUMB_TARGET_SIZE, uri, - mContentResolver, null, null); + mContentResolver); } return bitmap; } @@ -369,21 +332,12 @@ public abstract class BaseImageList implements IImageList { } public void checkThumbnails(ThumbCheckCallback cb, int totalThumbnails) { - Cursor c = Images.Media.query(mContentResolver, mBaseUri, - new String[] { "_id", "mini_thumb_magic" }, - thumbnailWhereClause(), thumbnailWhereClauseArgs(), - "_id ASC"); - - int count = c.getCount(); - c.close(); - if (!ImageManager.hasStorage()) { Log.v(TAG, "bailing from the image checker thread -- no storage"); return; } - c = getCursor(); - int current = 0; + Cursor c = getCursor(); for (int i = 0; i < c.getCount(); i++) { try { checkThumbnail(null, c, i); @@ -393,28 +347,20 @@ public abstract class BaseImageList implements IImageList { break; } if (cb != null) { - if (!cb.checking(current, totalThumbnails)) { + if (!cb.checking(i, totalThumbnails)) { break; } } - current += 1; } } - protected String thumbnailWhereClause() { - return MINITHUMB_IS_NULL + " and " + WHERE_CLAUSE; - } - - protected String[] thumbnailWhereClauseArgs() { - return ACCEPTABLE_IMAGE_TYPES; - } - public void commitChanges() { synchronized (mCursor) { mCursor.commitUpdates(); requery(); } } + protected Uri contentUri(long id) { try { // does our uri already have an id (single image query)? @@ -478,7 +424,7 @@ public abstract class BaseImageList implements IImageList { } if (moved) { try { - long id = c.getLong(0); + long id = c.getLong(indexId()); long miniThumbMagic = 0; int rotation = 0; if (indexMiniThumbMagic() != -1) { @@ -531,24 +477,22 @@ public abstract class BaseImageList implements IImageList { mMiniThumbFile.saveMiniThumbToFile(data, id, magic); } - protected abstract int indexOrientation(); + protected abstract int indexId(); - protected abstract int indexDateTaken(); + protected abstract int indexData(); protected abstract int indexMimeType(); - protected abstract int indexData(); - - protected abstract int indexId(); + protected abstract int indexDateTaken(); protected abstract int indexMiniThumbMagic(); + protected abstract int indexOrientation(); + protected abstract int indexTitle(); protected abstract int indexDisplayName(); - protected abstract int indexThumbId(); - protected IImage make(long id, long miniThumbMagic, ContentResolver cr, IImageList list, int index, int rotation) { return null; diff --git a/src/com/android/camera/gallery/DrmImageList.java b/src/com/android/camera/gallery/DrmImageList.java index ab1a02b..e9db66f 100644 --- a/src/com/android/camera/gallery/DrmImageList.java +++ b/src/com/android/camera/gallery/DrmImageList.java @@ -19,7 +19,6 @@ package com.android.camera.gallery; import com.android.camera.ImageManager; import android.content.ContentResolver; -import android.content.Context; import android.database.Cursor; import android.graphics.Bitmap; import android.net.Uri; @@ -36,9 +35,9 @@ public class DrmImageList extends ImageList implements IImageList { DrmStore.Audio.MIME_TYPE, }; - public DrmImageList(Context ctx, ContentResolver cr, Uri imageUri, + public DrmImageList(ContentResolver cr, Uri imageUri, int sort, String bucketId) { - super(ctx, cr, imageUri, null, sort, bucketId); + super(cr, imageUri, null, sort, bucketId); } @Override @@ -97,13 +96,14 @@ public class DrmImageList extends ImageList implements IImageList { return new DrmImage(id, mContentResolver, this, index); } + @Override - protected int indexOrientation() { + protected int indexId() { return -1; } @Override - protected int indexDateTaken() { + protected int indexData() { return -1; } @@ -113,7 +113,7 @@ public class DrmImageList extends ImageList implements IImageList { } @Override - protected int indexId() { + protected int indexDateTaken() { return -1; } @@ -123,17 +123,17 @@ public class DrmImageList extends ImageList implements IImageList { } @Override - protected int indexTitle() { + protected int indexOrientation() { return -1; } @Override - protected int indexDisplayName() { + protected int indexTitle() { return -1; } @Override - protected int indexThumbId() { + protected int indexDisplayName() { return -1; } diff --git a/src/com/android/camera/gallery/IImageList.java b/src/com/android/camera/gallery/IImageList.java index f9257e5..406801e 100644 --- a/src/com/android/camera/gallery/IImageList.java +++ b/src/com/android/camera/gallery/IImageList.java @@ -54,7 +54,7 @@ public interface IImageList { } public abstract void checkThumbnails( - IImageList.ThumbCheckCallback cb, int totalCount); + IImageList.ThumbCheckCallback cb, int totalThumbnails); public abstract void commitChanges(); diff --git a/src/com/android/camera/gallery/Image.java b/src/com/android/camera/gallery/Image.java index 9547a1f..7f1e2a7 100644 --- a/src/com/android/camera/gallery/Image.java +++ b/src/com/android/camera/gallery/Image.java @@ -28,6 +28,7 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; import android.os.ParcelFileDescriptor; +import android.provider.BaseColumns; import android.provider.MediaStore.Images.Thumbnails; import android.util.Log; @@ -322,16 +323,22 @@ public class Image extends BaseImage implements IImage { return true; } + private static final String[] THUMB_PROJECTION = new String[] { + BaseColumns._ID, + }; + public Bitmap thumbBitmap() { Bitmap bitmap = null; if (mContainer.mThumbUri != null) { Cursor c = mContentResolver.query( - mContainer.mThumbUri, BaseImageList.THUMB_PROJECTION, + mContainer.mThumbUri, THUMB_PROJECTION, Thumbnails.IMAGE_ID + "=?", new String[] { String.valueOf(fullSizeImageId()) }, null); try { - if (c.moveToFirst()) bitmap = decodeCurrentImage(c); + if (c.moveToFirst()) { + bitmap = decodeCurrentImage(c.getLong(0)); + } } catch (RuntimeException ex) { // sdcard removed? return null; @@ -354,10 +361,9 @@ public class Image extends BaseImage implements IImage { return bitmap; } - private Bitmap decodeCurrentImage(Cursor c) { + private Bitmap decodeCurrentImage(long id) { Uri thumbUri = ContentUris.withAppendedId( - mContainer.mThumbUri, - c.getLong(ImageList.INDEX_THUMB_ID)); + mContainer.mThumbUri, id); ParcelFileDescriptor pfdInput; Bitmap bitmap = null; try { diff --git a/src/com/android/camera/gallery/ImageList.java b/src/com/android/camera/gallery/ImageList.java index 23ad454..6d379ae 100644 --- a/src/com/android/camera/gallery/ImageList.java +++ b/src/com/android/camera/gallery/ImageList.java @@ -16,22 +16,18 @@ package com.android.camera.gallery; -import com.android.camera.BitmapManager; import com.android.camera.ImageManager; import com.android.camera.Util; import android.content.ContentResolver; -import android.content.Context; import android.database.Cursor; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.net.Uri; -import android.os.ParcelFileDescriptor; +import android.provider.BaseColumns; +import android.provider.MediaStore.MediaColumns; import android.provider.MediaStore.Images; import android.provider.MediaStore.Images.ImageColumns; import android.util.Log; -import java.io.IOException; import java.util.HashMap; /** @@ -65,14 +61,10 @@ public class ImageList extends BaseImageList implements IImageList { * ImageList constructor. * @param cr ContentResolver */ - public ImageList(Context ctx, ContentResolver cr, Uri imageUri, + public ImageList(ContentResolver cr, Uri imageUri, Uri thumbUri, int sort, String bucketId) { - super(ctx, cr, imageUri, sort, bucketId); - mBaseUri = imageUri; + super(cr, imageUri, sort, bucketId); mThumbUri = thumbUri; - mSort = sort; - - mContentResolver = cr; mCursor = createCursor(); if (mCursor == null) { @@ -99,19 +91,40 @@ public class ImageList extends BaseImageList implements IImageList { protected Cursor createCursor() { Cursor c = Images.Media.query( - mContentResolver, mBaseUri, BaseImageList.IMAGE_PROJECTION, + mContentResolver, mBaseUri, IMAGE_PROJECTION, whereClause(), whereClauseArgs(), sortOrder()); return c; } + static final String[] IMAGE_PROJECTION = new String[] { + BaseColumns._ID, + MediaColumns.DATA, + ImageColumns.DATE_TAKEN, + ImageColumns.MINI_THUMB_MAGIC, + ImageColumns.ORIENTATION, + ImageColumns.MIME_TYPE}; + + private static final int INDEX_ID + = Util.indexOf(IMAGE_PROJECTION, BaseColumns._ID); + private static final int INDEX_DATA = + Util.indexOf(IMAGE_PROJECTION, MediaColumns.DATA); + private static final int INDEX_MIME_TYPE = + Util.indexOf(IMAGE_PROJECTION, MediaColumns.MIME_TYPE); + private static final int INDEX_DATE_TAKEN = + Util.indexOf(IMAGE_PROJECTION, ImageColumns.DATE_TAKEN); + private static final int INDEX_MINI_THUMB_MAGIC = + Util.indexOf(IMAGE_PROJECTION, ImageColumns.MINI_THUMB_MAGIC); + private static final int INDEX_ORIENTATION = + Util.indexOf(IMAGE_PROJECTION, ImageColumns.ORIENTATION); + @Override - protected int indexOrientation() { - return INDEX_ORIENTATION; + protected int indexId() { + return INDEX_ID; } @Override - protected int indexDateTaken() { - return INDEX_DATE_TAKEN; + protected int indexData() { + return INDEX_DATA; } @Override @@ -120,18 +133,18 @@ public class ImageList extends BaseImageList implements IImageList { } @Override - protected int indexData() { - return INDEX_DATA; + protected int indexDateTaken() { + return INDEX_DATE_TAKEN; } @Override - protected int indexId() { - return INDEX_ID; + protected int indexMiniThumbMagic() { + return INDEX_MINI_THUMB_MAGIC; } @Override - protected int indexMiniThumbMagic() { - return INDEX_MINI_THUMB_MAGIC; + protected int indexOrientation() { + return INDEX_ORIENTATION; } @Override @@ -145,11 +158,6 @@ public class ImageList extends BaseImageList implements IImageList { } @Override - protected int indexThumbId() { - return INDEX_THUMB_ID; - } - - @Override protected IImage make(long id, long miniThumbMagic, ContentResolver cr, IImageList list, int index, int rotation) { return new Image(id, miniThumbMagic, mContentResolver, this, index, @@ -165,6 +173,4 @@ public class ImageList extends BaseImageList implements IImageList { return Images.Media.DATE_TAKEN + ascending + "," + Images.Media._ID + ascending; } - } - diff --git a/src/com/android/camera/gallery/SingleImageList.java b/src/com/android/camera/gallery/SingleImageList.java index d7812bb..a182fc4 100644 --- a/src/com/android/camera/gallery/SingleImageList.java +++ b/src/com/android/camera/gallery/SingleImageList.java @@ -16,15 +16,10 @@ package com.android.camera.gallery; -import com.android.camera.BitmapManager; import com.android.camera.ImageManager; -import com.android.camera.Util; import android.content.ContentResolver; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.net.Uri; -import android.os.ParcelFileDescriptor; import android.util.Log; import java.util.HashMap; @@ -40,7 +35,7 @@ public class SingleImageList extends BaseImageList implements IImageList { private IImage mSingleImage; public SingleImageList(ContentResolver cr, Uri uri) { - super(null, cr, uri, ImageManager.SORT_ASCENDING, null); + super(cr, uri, ImageManager.SORT_ASCENDING, null); mSingleImage = new UriImage(this, cr, uri); } @@ -70,16 +65,16 @@ public class SingleImageList extends BaseImageList implements IImageList { @Override public IImage getImageForUri(Uri uri) { - return uri.equals(mUri) ? mSingleImage : null; + return uri.equals(mBaseUri) ? mSingleImage : null; } @Override - protected int indexOrientation() { + protected int indexId() { return -1; } @Override - protected int indexDateTaken() { + protected int indexData() { return -1; } @@ -89,17 +84,17 @@ public class SingleImageList extends BaseImageList implements IImageList { } @Override - protected int indexId() { + protected int indexDateTaken() { return -1; } @Override - protected int indexData() { + protected int indexMiniThumbMagic() { return -1; } @Override - protected int indexMiniThumbMagic() { + protected int indexOrientation() { return -1; } @@ -112,9 +107,4 @@ public class SingleImageList extends BaseImageList implements IImageList { protected int indexDisplayName() { return -1; } - - @Override - protected int indexThumbId() { - return -1; - } } diff --git a/src/com/android/camera/gallery/VideoList.java b/src/com/android/camera/gallery/VideoList.java index b728279..cb8a323 100644 --- a/src/com/android/camera/gallery/VideoList.java +++ b/src/com/android/camera/gallery/VideoList.java @@ -20,21 +20,14 @@ import com.android.camera.ImageManager; import com.android.camera.Util; import android.content.ContentResolver; -import android.content.Context; import android.database.Cursor; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.media.MediaPlayer; import android.net.Uri; -import android.os.ParcelFileDescriptor; import android.provider.BaseColumns; import android.provider.MediaStore.Images; import android.provider.MediaStore.Video; import android.provider.MediaStore.Video.VideoColumns; -import android.util.Config; import android.util.Log; -import java.io.IOException; import java.util.HashMap; /** @@ -56,27 +49,23 @@ public class VideoList extends BaseImageList implements IImageList { Video.Media.MINI_THUMB_MAGIC, Video.Media.MIME_TYPE}; - static final int INDEX_ID = indexOf(Video.Media._ID); - static final int INDEX_DATA = indexOf(Video.Media.DATA); - static final int INDEX_DATE_TAKEN = indexOf(Video.Media.DATE_TAKEN); - static final int INDEX_TITLE = indexOf(Video.Media.TITLE); - static final int INDEX_DISPLAY_NAME = + private static final int INDEX_ID = indexOf(Video.Media._ID); + private static final int INDEX_DATA = indexOf(Video.Media.DATA); + private static final int INDEX_DATE_TAKEN = indexOf(Video.Media.DATE_TAKEN); + private static final int INDEX_TITLE = indexOf(Video.Media.TITLE); + private static final int INDEX_DISPLAY_NAME = indexOf(Video.Media.DISPLAY_NAME); - static final int INDEX_MIME_TYPE = indexOf(Video.Media.MIME_TYPE); - static final int INDEX_TAGS = indexOf(Video.Media.TAGS); - static final int INDEX_CATEGORY = indexOf(Video.Media.CATEGORY); - static final int INDEX_LANGUAGE = indexOf(Video.Media.LANGUAGE); - static final int INDEX_MINI_THUMB_MAGIC = + private static final int INDEX_MIME_TYPE = indexOf(Video.Media.MIME_TYPE); + private static final int INDEX_MINI_THUMB_MAGIC = indexOf(Video.Media.MINI_THUMB_MAGIC); - static final int INDEX_THUMB_ID = indexOf(BaseColumns._ID); private static int indexOf(String field) { return Util.indexOf(sProjection, field); } - public VideoList(Context ctx, ContentResolver cr, Uri uri, Uri thumbUri, + public VideoList(ContentResolver cr, Uri uri, Uri thumbUri, int sort, String bucketId) { - super(ctx, cr, uri, sort, bucketId); + super(cr, uri, sort, bucketId); mCursor = createCursor(); if (mCursor == null) { @@ -84,10 +73,7 @@ public class VideoList extends BaseImageList implements IImageList { throw new UnsupportedOperationException(); } - if (mCursor == null) { - throw new UnsupportedOperationException(); - } - if (mCursor != null && mCursor.moveToFirst()) { + if (mCursor.moveToFirst()) { int row = 0; do { long imageId = mCursor.getLong(indexId()); @@ -129,16 +115,6 @@ public class VideoList extends BaseImageList implements IImageList { return null; } - @Override - protected String thumbnailWhereClause() { - return MINITHUMB_IS_NULL; - } - - @Override - protected String[] thumbnailWhereClauseArgs() { - return null; - } - protected Cursor createCursor() { Cursor c = Images.Media.query( mContentResolver, mBaseUri, sProjection, @@ -147,13 +123,13 @@ public class VideoList extends BaseImageList implements IImageList { } @Override - protected int indexOrientation() { - return -1; + protected int indexId() { + return INDEX_ID; } @Override - protected int indexDateTaken() { - return INDEX_DATE_TAKEN; + protected int indexData() { + return INDEX_DATA; } @Override @@ -162,18 +138,18 @@ public class VideoList extends BaseImageList implements IImageList { } @Override - protected int indexData() { - return INDEX_DATA; + protected int indexDateTaken() { + return INDEX_DATE_TAKEN; } @Override - protected int indexId() { - return INDEX_ID; + protected int indexMiniThumbMagic() { + return INDEX_MINI_THUMB_MAGIC; } @Override - protected int indexMiniThumbMagic() { - return INDEX_MINI_THUMB_MAGIC; + protected int indexOrientation() { + return -1; } @Override @@ -187,11 +163,6 @@ public class VideoList extends BaseImageList implements IImageList { } @Override - protected int indexThumbId() { - return INDEX_THUMB_ID; - } - - @Override protected IImage make(long id, long miniThumbMagic, ContentResolver cr, IImageList list, int index, int rotation) { return new VideoObject(id, miniThumbMagic, mContentResolver, this, diff --git a/src/com/android/camera/gallery/VideoObject.java b/src/com/android/camera/gallery/VideoObject.java index 4620fda..60a8aa4 100644 --- a/src/com/android/camera/gallery/VideoObject.java +++ b/src/com/android/camera/gallery/VideoObject.java @@ -99,34 +99,11 @@ public class VideoObject extends BaseImage implements IImage { return mId; } - public String getCategory() { - return getStringEntry(VideoList.INDEX_CATEGORY); - } - @Override public int getHeight() { return 0; } - public String getLanguage() { - return getStringEntry(VideoList.INDEX_LANGUAGE); - } - - private String getStringEntry(int entryName) { - String entry = null; - Cursor c = getCursor(); - synchronized (c) { - if (c.moveToPosition(getRow())) { - entry = c.getString(entryName); - } - } - return entry; - } - - public String getTags() { - return getStringEntry(VideoList.INDEX_TAGS); - } - @Override public int getWidth() { return 0; @@ -136,33 +113,12 @@ public class VideoObject extends BaseImage implements IImage { return false; } - public boolean isDrm() { - return false; - } - - public boolean rotateImageBy(int degrees) { + public boolean isDrm() { return false; } - public void setCategory(String category) { - setStringEntry(category, VideoList.INDEX_CATEGORY); - } - - public void setLanguage(String language) { - setStringEntry(language, VideoList.INDEX_LANGUAGE); - } - - private void setStringEntry(String entry, int entryName) { - Cursor c = getCursor(); - synchronized (c) { - if (c.moveToPosition(getRow())) { - c.updateString(entryName, entry); - } - } - } - - public void setTags(String tags) { - setStringEntry(tags, VideoList.INDEX_TAGS); + public boolean rotateImageBy(int degrees) { + return false; } public Bitmap thumbBitmap() { |