Home | History | Annotate | Download | only in gallery
      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 
     17 package com.android.camera.gallery;
     18 
     19 import android.content.ContentResolver;
     20 import android.database.Cursor;
     21 import android.net.Uri;
     22 import android.provider.MediaStore.Images;
     23 import android.provider.MediaStore.Video.Media;
     24 
     25 /**
     26  * A collection of all the <code>VideoObject</code> in gallery.
     27  */
     28 public class VideoList extends BaseImageList {
     29 
     30     @SuppressWarnings("unused")
     31     private static final String TAG = "BaseImageList";
     32 
     33     private static final String[] VIDEO_PROJECTION = new String[] {
     34             Media._ID,
     35             Media.DATE_TAKEN,
     36             Media.MINI_THUMB_MAGIC,
     37             Media.DATE_MODIFIED};
     38 
     39     private static final int INDEX_ID = 0;
     40     private static final int INDEX_DATE_TAKEN = 1;
     41     private static final int INDEX_MIMI_THUMB_MAGIC = 2;
     42     private static final int INDEX_DATE_MODIFIED = 3;
     43 
     44     @Override
     45     protected BaseImage loadImageFromCursor(Cursor cursor) {
     46         long id = cursor.getLong(INDEX_ID);
     47         long dateTaken = cursor.getLong(INDEX_DATE_TAKEN);
     48         if (dateTaken == 0) {
     49             dateTaken = cursor.getLong(INDEX_DATE_MODIFIED) * 1000;
     50         }
     51         long miniThumbMagic = cursor.getLong(INDEX_MIMI_THUMB_MAGIC);
     52         return new VideoObject(mContentResolver,
     53                 id, contentUri(id),
     54                 miniThumbMagic, dateTaken);
     55     }
     56 
     57     public VideoList(ContentResolver resolver, Uri uri, int sort,
     58             String bucketId) {
     59         super(resolver, uri, sort, bucketId);
     60     }
     61 
     62     protected String whereClause() {
     63         return mBucketId != null
     64                 ? Images.Media.BUCKET_ID + " = '" + mBucketId + "'"
     65                 : null;
     66     }
     67 
     68     protected String[] whereClauseArgs() {
     69         return null;
     70     }
     71 
     72     @Override
     73     protected Cursor createCursor() {
     74         Cursor c = Images.Media.query(
     75                 mContentResolver, mBaseUri, VIDEO_PROJECTION,
     76                 whereClause(), whereClauseArgs(), sortOrder());
     77         return c;
     78     }
     79 }
     80