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.app.Activity;
     20 import android.content.ContentResolver;
     21 import android.content.Context;
     22 import android.graphics.drawable.Drawable;
     23 import android.net.Uri;
     24 import android.util.Log;
     25 import android.view.View;
     26 
     27 import com.android.camera.ui.FilmStripView;
     28 import com.android.camera.util.PhotoSphereHelper;
     29 
     30 /**
     31  * A LocalData that does nothing but only shows a view.
     32  */
     33 public class SimpleViewData implements LocalData {
     34     private static final String TAG = "CAM_SimpleViewData";
     35 
     36     private final int mWidth;
     37     private final int mHeight;
     38     private final View mView;
     39     private final long mDateTaken;
     40     private final long mDateModified;
     41 
     42     public SimpleViewData(
     43             View v, int width, int height,
     44             int dateTaken, int dateModified) {
     45         mView = v;
     46         mWidth = width;
     47         mHeight = height;
     48         mDateTaken = dateTaken;
     49         mDateModified = dateModified;
     50     }
     51 
     52     @Override
     53     public long getDateTaken() {
     54         return mDateTaken;
     55     }
     56 
     57     @Override
     58     public long getDateModified() {
     59         return mDateModified;
     60     }
     61 
     62     @Override
     63     public String getTitle() {
     64         return "";
     65     }
     66 
     67     @Override
     68     public int getWidth() {
     69         return mWidth;
     70     }
     71 
     72     @Override
     73     public int getHeight() {
     74         return mHeight;
     75     }
     76 
     77     @Override
     78     public int getOrientation() {
     79         return 0;
     80     }
     81 
     82     @Override
     83     public int getViewType() {
     84         return FilmStripView.ImageData.VIEW_TYPE_REMOVABLE;
     85     }
     86 
     87     @Override
     88     public String getPath() {
     89         return "";
     90     }
     91 
     92     @Override
     93     public Uri getContentUri() {
     94         return Uri.EMPTY;
     95     }
     96 
     97     @Override
     98     public int getLocalDataType() {
     99         return LOCAL_VIEW;
    100     }
    101 
    102     @Override
    103     public LocalData refresh(ContentResolver resolver) {
    104         return null;
    105     }
    106 
    107     @Override
    108     public boolean isUIActionSupported(int action) {
    109         return false;
    110     }
    111 
    112     @Override
    113     public boolean isDataActionSupported(int action) {
    114         return false;
    115     }
    116 
    117     @Override
    118     public boolean delete(Context c) {
    119         return false;
    120     }
    121 
    122     @Override
    123     public View getView(Activity activity, int width, int height, Drawable placeHolder,
    124             LocalDataAdapter adapter) {
    125         return mView;
    126     }
    127 
    128     @Override
    129     public void prepare() {
    130         // do nothing.
    131     }
    132 
    133     @Override
    134     public void recycle() {
    135         // do nothing.
    136     }
    137 
    138     @Override
    139     public void isPhotoSphere(Context context, PanoramaSupportCallback callback) {
    140         // Not a photo sphere panorama.
    141         callback.panoramaInfoAvailable(false, false);
    142     }
    143 
    144     @Override
    145     public void viewPhotoSphere(PhotoSphereHelper.PanoramaViewHelper helper) {
    146         // do nothing.
    147     }
    148 
    149     @Override
    150     public void onFullScreen(boolean fullScreen) {
    151         // do nothing.
    152     }
    153 
    154     @Override
    155     public boolean canSwipeInFullScreen() {
    156         return true;
    157     }
    158 
    159     @Override
    160     public MediaDetails getMediaDetails(Context context) {
    161         return null;
    162     }
    163 
    164     @Override
    165     public double[] getLatLong() {
    166         return null;
    167     }
    168 
    169     @Override
    170     public boolean isPhoto() {
    171         return false;
    172     }
    173 
    174     @Override
    175     public String getMimeType() {
    176         return null;
    177     }
    178 
    179     @Override
    180     public boolean rotate90Degrees(Context context, LocalDataAdapter adapter,
    181             int currentDataId, boolean clockwise) {
    182         // We don't support rotation for SimpleViewData.
    183         Log.w(TAG, "Unexpected call in rotate90Degrees()");
    184         return false;
    185     }
    186 
    187     @Override
    188     public long getSizeInBytes() {
    189         return 0;
    190     }
    191 
    192     @Override
    193     public long getContentId() {
    194         return -1;
    195     }
    196 }
    197