Home | History | Annotate | Download | only in data
      1 /*
      2  * Copyright (C) 2012 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 android.graphics.Bitmap;
     20 import android.graphics.BitmapRegionDecoder;
     21 
     22 import com.android.gallery3d.ui.ScreenNail;
     23 import com.android.gallery3d.util.ThreadPool.Job;
     24 import com.android.gallery3d.util.ThreadPool.JobContext;
     25 
     26 // SnailItem is a MediaItem which can provide a ScreenNail. This is
     27 // used so we can show an foreign component (like an
     28 // android.view.View) instead of a Bitmap.
     29 public class SnailItem extends MediaItem {
     30     @SuppressWarnings("unused")
     31     private static final String TAG = "SnailItem";
     32     private ScreenNail mScreenNail;
     33 
     34     public SnailItem(Path path) {
     35         super(path, nextVersionNumber());
     36     }
     37 
     38     @Override
     39     public Job<Bitmap> requestImage(int type) {
     40         // nothing to return
     41         return new Job<Bitmap>() {
     42             @Override
     43             public Bitmap run(JobContext jc) {
     44                 return null;
     45             }
     46         };
     47     }
     48 
     49     @Override
     50     public Job<BitmapRegionDecoder> requestLargeImage() {
     51         // nothing to return
     52         return new Job<BitmapRegionDecoder>() {
     53             @Override
     54             public BitmapRegionDecoder run(JobContext jc) {
     55                 return null;
     56             }
     57         };
     58     }
     59 
     60     // We do not provide requestImage or requestLargeImage, instead we
     61     // provide a ScreenNail.
     62     @Override
     63     public ScreenNail getScreenNail() {
     64         return mScreenNail;
     65     }
     66 
     67     @Override
     68     public String getMimeType() {
     69         return "";
     70     }
     71 
     72     // Returns width and height of the media item.
     73     // Returns 0, 0 if the information is not available.
     74     @Override
     75     public int getWidth() {
     76         return 0;
     77     }
     78 
     79     @Override
     80     public int getHeight() {
     81         return 0;
     82     }
     83 
     84     //////////////////////////////////////////////////////////////////////////
     85     //  Extra methods for SnailItem
     86     //////////////////////////////////////////////////////////////////////////
     87 
     88     public void setScreenNail(ScreenNail screenNail) {
     89         mScreenNail = screenNail;
     90     }
     91 
     92     public void updateVersion() {
     93         mDataVersion = nextVersionNumber();
     94     }
     95 }
     96