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     private static final String TAG = "SnailItem";
     31     private ScreenNail mScreenNail;
     32 
     33     public SnailItem(Path path) {
     34         super(path, nextVersionNumber());
     35     }
     36 
     37     @Override
     38     public Job<Bitmap> requestImage(int type) {
     39         // nothing to return
     40         return new Job<Bitmap>() {
     41             public Bitmap run(JobContext jc) {
     42                 return null;
     43             }
     44         };
     45     }
     46 
     47     @Override
     48     public Job<BitmapRegionDecoder> requestLargeImage() {
     49         // nothing to return
     50         return new Job<BitmapRegionDecoder>() {
     51             public BitmapRegionDecoder run(JobContext jc) {
     52                 return null;
     53             }
     54         };
     55     }
     56 
     57     // We do not provide requestImage or requestLargeImage, instead we
     58     // provide a ScreenNail.
     59     @Override
     60     public ScreenNail getScreenNail() {
     61         return mScreenNail;
     62     }
     63 
     64     @Override
     65     public String getMimeType() {
     66         return "";
     67     }
     68 
     69     // Returns width and height of the media item.
     70     // Returns 0, 0 if the information is not available.
     71     @Override
     72     public int getWidth() {
     73         return 0;
     74     }
     75 
     76     @Override
     77     public int getHeight() {
     78         return 0;
     79     }
     80 
     81     //////////////////////////////////////////////////////////////////////////
     82     //  Extra methods for SnailItem
     83     //////////////////////////////////////////////////////////////////////////
     84 
     85     public void setScreenNail(ScreenNail screenNail) {
     86         mScreenNail = screenNail;
     87     }
     88 
     89     public void updateVersion() {
     90         mDataVersion = nextVersionNumber();
     91     }
     92 }
     93