Home | History | Annotate | Download | only in filmstrip
      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.filmstrip;
     18 
     19 import android.content.Context;
     20 import android.net.Uri;
     21 import android.view.View;
     22 
     23 /**
     24  * Common interface for all images in the filmstrip.
     25  */
     26 public interface ImageData {
     27 
     28     // View types.
     29     public static final int VIEW_TYPE_NONE = 0;
     30     public static final int VIEW_TYPE_STICKY = 1;
     31     public static final int VIEW_TYPE_REMOVABLE = 2;
     32 
     33     // Actions allowed to be performed on the image data.
     34     // The actions are defined bit-wise so we can use bit operations like
     35     // | and &.
     36     public static final int ACTION_NONE = 0;
     37     public static final int ACTION_PROMOTE = 1;
     38     public static final int ACTION_DEMOTE = (1 << 1);
     39     /**
     40      * For image data that supports zoom, it should also provide a valid
     41      * content uri.
     42      */
     43     public static final int ACTION_ZOOM = (1 << 2);
     44 
     45     /**
     46      * SIZE_FULL can be returned by {@link ImageData#getWidth()} and
     47      * {@link ImageData#getHeight()}. When SIZE_FULL is returned for
     48      * width/height, it means the the width or height will be disregarded
     49      * when deciding the view size of this ImageData, just use full screen
     50      * size.
     51      */
     52     public static final int SIZE_FULL = -2;
     53 
     54     /**
     55      * Returns the width in pixels of the image before orientation applied.
     56      * The final layout of the view returned by
     57      * {@link DataAdapter#getView(Context, int)} will
     58      * preserve the aspect ratio of
     59      * {@link ImageData#getWidth()} and
     60      * {@link ImageData#getHeight()}.
     61      */
     62     public int getWidth();
     63 
     64     /**
     65      * Returns the height in pixels of the image before orientation applied.
     66      * The final layout of the view returned by
     67      * {@link DataAdapter#getView(Context, int)} will
     68      * preserve the aspect ratio of
     69      * {@link ImageData#getWidth()} and
     70      * {@link ImageData#getHeight()}.
     71      */
     72     public int getHeight();
     73 
     74     /**
     75      * Returns the rotation of the image in degrees clockwise. The valid values
     76      * are 0, 90, 180, and 270.
     77      */
     78     public int getRotation();
     79 
     80     /** Returns the image data type. The current valid values are
     81      * {@code VIEW_TYPE_*}.
     82      */
     83     public int getViewType();
     84 
     85     /**
     86      * Returns the coordinates of this item.
     87      *
     88      * @return A 2-element array containing {latitude, longitude}, or null,
     89      *         if no position is known for this item.
     90      */
     91     public double[] getLatLong();
     92 
     93     /**
     94      * Checks if the UI action is supported.
     95      *
     96      * @param action The UI actions to check.
     97      * @return Whether at all of the actions set in {@code action} are
     98      * supported.
     99      */
    100     public boolean isUIActionSupported(int action);
    101 
    102     /**
    103      * Gives the data a hint when its view is going to be displayed.
    104      * {@code FilmStripView} should always call this function before showing
    105      * its corresponding view every time.
    106      */
    107     public void prepare();
    108 
    109     /**
    110      * Gives the data a hint when its view is going to be removed from the
    111      * view hierarchy. {@code FilmStripView} should always call this
    112      * function after its corresponding view is removed from the view
    113      * hierarchy.
    114      */
    115     public void recycle(View view);
    116 
    117     /**
    118      * @return The URI of this data. Must be a unique one and not null.
    119      */
    120     public Uri getUri();
    121 }
    122