diff options
author | Owen Lin <owenlin@google.com> | 2009-05-05 22:11:15 -0700 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2009-05-28 20:45:39 -0700 |
commit | bbc2f2f15a865cf0330cd78a6ea67177c5863b3b (patch) | |
tree | f552459aa697f01aa5c93ed584a3b1e573eeb4c9 /src/com/android/camera/gallery/DrmImageList.java | |
parent | ff73b96a2047b51a0a4f489fb4a9a283b66cf2b5 (diff) | |
download | packages_apps_LegacyCamera-bbc2f2f15a865cf0330cd78a6ea67177c5863b3b.zip packages_apps_LegacyCamera-bbc2f2f15a865cf0330cd78a6ea67177c5863b3b.tar.gz packages_apps_LegacyCamera-bbc2f2f15a865cf0330cd78a6ea67177c5863b3b.tar.bz2 |
Simplify the database code by keeping small data in memory.
Diffstat (limited to 'src/com/android/camera/gallery/DrmImageList.java')
-rw-r--r-- | src/com/android/camera/gallery/DrmImageList.java | 74 |
1 files changed, 23 insertions, 51 deletions
diff --git a/src/com/android/camera/gallery/DrmImageList.java b/src/com/android/camera/gallery/DrmImageList.java index 383211a..2a55343 100644 --- a/src/com/android/camera/gallery/DrmImageList.java +++ b/src/com/android/camera/gallery/DrmImageList.java @@ -29,12 +29,17 @@ import android.provider.DrmStore; */ public class DrmImageList extends ImageList implements IImageList { + // TODO: get other field from database too ? private static final String[] DRM_IMAGE_PROJECTION = new String[] { - DrmStore.Audio._ID, - DrmStore.Audio.DATA, - DrmStore.Audio.MIME_TYPE, + DrmStore.Images._ID, + DrmStore.Images.DATA, + DrmStore.Images.MIME_TYPE, }; + private static final int INDEX_ID = 0; + private static final int INDEX_DATA_PATH = 1; + private static final int INDEX_MIME_TYPE = 2; + public DrmImageList(ContentResolver cr, Uri imageUri, int sort, String bucketId) { super(cr, imageUri, null, sort, bucketId); @@ -52,9 +57,12 @@ public class DrmImageList extends ImageList implements IImageList { private static class DrmImage extends Image { - protected DrmImage(long id, ContentResolver cr, - BaseImageList container, int cursorRow) { - super(id, 0, cr, container, cursorRow, 0); + protected DrmImage(BaseImageList container, ContentResolver cr, + long id, int index, Uri uri, String dataPath, long miniThumbMagic, + String mimeType, long dateTaken, String title, + String displayName, int rotation) { + super(container, cr, id, index, uri, dataPath, miniThumbMagic, + mimeType, dateTaken, title, displayName, rotation); } @Override @@ -84,54 +92,18 @@ public class DrmImageList extends ImageList implements IImageList { } @Override - protected IImage make(long id, long miniThumbMagic, ContentResolver cr, - IImageList list, int index, int rotation) { - return new DrmImage(id, mContentResolver, this, index); - } - - - @Override - protected int indexId() { - return -1; - } - - @Override - protected int indexData() { - return -1; - } - - @Override - protected int indexMimeType() { - return -1; - } - - @Override - protected int indexDateTaken() { - return -1; - } - - @Override - protected int indexMiniThumbMagic() { - return -1; - } - - @Override - protected int indexOrientation() { - return -1; - } - - @Override - protected int indexTitle() { - return -1; - } - - @Override - protected int indexDisplayName() { - return -1; + protected BaseImage loadImageFromCursor(Cursor cursor) { + long id = cursor.getLong(INDEX_ID); + String dataPath = cursor.getString(INDEX_DATA_PATH); + String mimeType = cursor.getString(INDEX_MIME_TYPE); + return new DrmImage(this, mContentResolver, id, cursor.getPosition(), + contentUri(id), dataPath, 0, mimeType, 0, "DrmImage-" + id, + "DrmImage-" + id, 0); } // TODO: Review this probably should be based on DATE_TAKEN same as images - private String sortOrder() { + @Override + protected String sortOrder() { String ascending = mSort == ImageManager.SORT_ASCENDING ? " ASC" : " DESC"; return DrmStore.Images.TITLE + ascending + "," + DrmStore.Images._ID; |