Home | History | Annotate | Download | only in data
      1 /*
      2  * Copyright (C) 2010 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.gallery3d.data;
     18 
     19 import com.android.gallery3d.util.ThreadPool.Job;
     20 
     21 import android.graphics.Bitmap;
     22 import android.graphics.BitmapRegionDecoder;
     23 
     24 // MediaItem represents an image or a video item.
     25 public abstract class MediaItem extends MediaObject {
     26     // NOTE: These type numbers are stored in the image cache, so it should not
     27     // not be changed without resetting the cache.
     28     public static final int TYPE_THUMBNAIL = 1;
     29     public static final int TYPE_MICROTHUMBNAIL = 2;
     30 
     31     public static final int THUMBNAIL_TARGET_SIZE = 640;
     32     public static final int MICROTHUMBNAIL_TARGET_SIZE = 200;
     33     public static final int CACHED_IMAGE_QUALITY = 95;
     34 
     35     public static final int IMAGE_READY = 0;
     36     public static final int IMAGE_WAIT = 1;
     37     public static final int IMAGE_ERROR = -1;
     38 
     39     public static final String MIME_TYPE_JPEG = "image/jpeg";
     40 
     41     // TODO: fix default value for latlng and change this.
     42     public static final double INVALID_LATLNG = 0f;
     43 
     44     public abstract Job<Bitmap> requestImage(int type);
     45     public abstract Job<BitmapRegionDecoder> requestLargeImage();
     46 
     47     public MediaItem(Path path, long version) {
     48         super(path, version);
     49     }
     50 
     51     public long getDateInMs() {
     52         return 0;
     53     }
     54 
     55     public String getName() {
     56         return null;
     57     }
     58 
     59     public void getLatLong(double[] latLong) {
     60         latLong[0] = INVALID_LATLNG;
     61         latLong[1] = INVALID_LATLNG;
     62     }
     63 
     64     public String[] getTags() {
     65         return null;
     66     }
     67 
     68     public Face[] getFaces() {
     69         return null;
     70     }
     71 
     72     // The rotation of the full-resolution image. By default, it returns the value of
     73     // getRotation().
     74     public int getFullImageRotation() {
     75         return getRotation();
     76     }
     77 
     78     public int getRotation() {
     79         return 0;
     80     }
     81 
     82     public long getSize() {
     83         return 0;
     84     }
     85 
     86     public abstract String getMimeType();
     87 
     88     // Returns width and height of the media item.
     89     // Returns 0, 0 if the information is not available.
     90     public abstract int getWidth();
     91     public abstract int getHeight();
     92 }
     93