Home | History | Annotate | Download | only in data
      1 /*
      2  * Copyright (C) 2013 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.data;
     18 
     19 import android.graphics.Bitmap;
     20 import android.net.Uri;
     21 import android.view.View;
     22 
     23 import com.android.camera.debug.Log;
     24 import com.android.camera.util.Size;
     25 import com.google.common.base.Optional;
     26 
     27 import javax.annotation.Nonnull;
     28 
     29 /**
     30  * An abstract interface that represents the Local filmstrip items.
     31  */
     32 public interface FilmstripItem {
     33     static final Log.Tag TAG = new Log.Tag("FilmstripItem");
     34 
     35     /**
     36      * An action callback to be used for actions on the filmstrip items.
     37      */
     38     public static interface VideoClickedCallback {
     39 
     40         /**
     41          * Plays the video with the given URI and title.
     42          */
     43         public void playVideo(Uri uri, String title);
     44     }
     45 
     46     /**
     47      * Returns the backing data for this filmstrip item.
     48      */
     49     public FilmstripItemData getData();
     50 
     51     /**
     52      * Returns the UI attributes of this filmstrip item.
     53      */
     54     public FilmstripItemAttributes getAttributes();
     55 
     56     /**
     57      * Returns the generic filmstrip item type.
     58      */
     59     public FilmstripItemType getItemViewType();
     60 
     61     /**
     62      * @return The media details (such as EXIF) for the data. {@code null} if not
     63      * available for the data.
     64      */
     65     public Optional<MediaDetails> getMediaDetails();
     66 
     67     /**
     68      * @return the metadata.
     69      */
     70     public Metadata getMetadata();
     71 
     72     /**
     73      * Gives the data a hint when its view is going to be removed from the view
     74      * hierarchy. {@code FilmStripView} should always call this function after its
     75      * corresponding view is removed from the view hierarchy.
     76      */
     77     public void recycle(@Nonnull View view);
     78 
     79     /**
     80      * Create or recycle an existing view (if provided) to render this item.
     81      *
     82      * @param adapter Data adapter for this data item.
     83      */
     84     public View getView(Optional<View> view,
     85           LocalFilmstripDataAdapter adapter, boolean isInProgress,
     86           VideoClickedCallback videoClickedCallback);
     87 
     88     /**
     89      * Configure the suggested width and height in pixels for this view to render at.
     90      *
     91      * @param widthPx Suggested width in pixels.
     92      * @param heightPx Suggested height in pixels.
     93      */
     94     public void setSuggestedSize(int widthPx, int heightPx);
     95 
     96     /**
     97      * Request to load a tiny preview image into the view as fast as possible.
     98      *
     99      * @param view View created by getView();
    100      */
    101     public void renderTiny(@Nonnull View view);
    102 
    103     /**
    104      * Request to load screen sized version of the image into the view.
    105      *
    106      * @param view View created by getView();
    107      */
    108     public void renderThumbnail(@Nonnull View view);
    109 
    110     /**
    111      * Request to load the highest possible resolution image supported.
    112      *
    113      * @param view View created by getView();
    114      */
    115     public void renderFullRes(@Nonnull View view);
    116 
    117     /**
    118      * Removes the data from the storage if possible.
    119      */
    120     public boolean delete();
    121 
    122     /**
    123      * Refresh the data content.
    124      *
    125      * @return A new LocalData object if success, null otherwise.
    126      */
    127     public FilmstripItem refresh();
    128 
    129     /**
    130      * @return a bitmap thumbnail for this item.
    131      */
    132     public Optional<Bitmap> generateThumbnail(int boundingWidthPx, int boundingHeightPx);
    133 
    134     /**
    135      * Dimensions of this item.
    136      *
    137      * @return physical width and height in pixels.
    138      */
    139     public Size getDimensions();
    140 
    141     /**
    142      * Returns the rotation of the image in degrees clockwise. The valid values
    143      * are 0, 90, 180, and 270.
    144      */
    145     public int getOrientation();
    146 }
    147